In c++, how can I implement a function with an int template argument indicating the tuple length and produce a std::tuple with that length?
E.g.
func<
Here is a recursive solution with alias template and it's implementable in C++11:
template
struct tuple_n{
template< typename...Args> using type = typename tuple_n::template type;
};
template
struct tuple_n<0, T> {
template using type = std::tuple;
};
template using tuple_of = typename tuple_n::template type<>;
For example if we want "tuple of 3 doubles"
we can write:
tuple_of<3, double> t;