Suppose I have a constexpr array for compilation and a variational class template with a set of off-peak parameters of the same type as the array elements.
My goal is to create an instance of a class template with values ββfrom an array:
struct Container { int containee[3]; }; constexpr Container makeContainer(); template <int... Elements> class Foo; Foo<makeContainer().containee[0], makeContainer().containee[1], makeContainer().containee[2]> foo;
The above code works well. However, I am very unhappy with the need to manually index the array whenever I need to instantiate an Foo template. I would like the compiler to do this automatically for me:
Foo<Magic(makeContainer().containee)> foo;
I did some RTFM in cppreference, but that didn't help. I know std::forward<>() , but it cannot be applied to template argument lists.
c ++ templates template-meta-programming constexpr variadic-templates
Pavel kirienko
source share