Open stigrj opened 5 years ago
Slightly improved version of the above code snippet (so it doesn't get lost on Slack):
template <std::size_t, typename T>
using ignore_val = T;
// Unused primary template
template <size_t N, typename=std::make_index_sequence<N>> class Collection;
// Partial specialization
template <size_t N, std::size_t... indices>
class Collection<N, std::index_sequence<indices...>> final {
public:
inline Collection(ignore_val<indices, MyType>... args) : mytypes_{args...} {}
void print() const {
for (const auto & mt: mytypes_) {
mt.print();
}
}
private:
std::array<MyType, N> mytypes_;
};
using MyTypes = Collection<3>;
From @robertodr in #161 :