Create std::array from variadic template

c++, c++11, templates, variadic-templates

Solution

If what you are wanting is to put all the `MyEnum` values into `array`, then you can unpack them into an initialiser list and initialise `array` with it initialise it with direct initialisation:

MyClass() : array {{ Args... }} { }

You need a fairly new compiler to use this syntax, however.

Thanks to Xeo for correcting my answer.

Problem

I'd like to achieve something like that: ``` #include <string> #include <array> enum class MyEnum{ A, B, C }; template<MyEnum... Args> class MyClass{ public: MyClass() { } private: std::array<MyEnum, sizeof...(Args)> array; }; ``` Now I have an array, which can hold all passed to template values. But how can I populate this array with template parameters?

Original source