You can do this without recursion by simply expanding the options package directly in std::tuple :
template<My_enum... Enums> struct Tuple { using type = std::tuple<typename Bind_type<Enums>::type...>; };
To more accurately answer your question, you can declare a variable primary template, and then write two specializations: if there are at least two parameters, and when there is only one:
//primary template, takes any number of My_enums template <My_enum... Enums> struct Tuple { //this case will be chosen if we instantiate a Tuple with no args using type = std::tuple<>; } //specialization for when there are at least two arguments template<My_enum First, My_enum Second, My_enum... Others> struct Tuple<First,Second,Others...> { using type = decltype(std::tuple_cat( typename Tuple<First>::type{}, typename Tuple<Second,Others...>::type{} )); }; //base case, only one argument left template<My_enum Last> struct Tuple<Last> { using type = std::tuple<typename Bind_type<Last>::type>; };
source share