Say you have a tuple type and you want to extract its template parameter pack in order to instantiate another template. If that is a type template, then I can have a utility like this:
template < typename Tuple, template <typename...> typename What >
struct PutTupleInT;
template < typename... Types, template <typename...> typename What >
struct PutTupleInT<std::tuple<Types...>, What>
{
using Result = What<Types...>;
};
But what if the desired template is a variable template? While template <typename...> typename What
is the "placeholder" for a type template, then what is the "placeholder" for a variable template?
I've tried the following for clang-4.0.0 (the only compiler by now that supports non-type template parameters with auto type), but it failed. Actually I am not sure if this is a correct syntax for C++17.
template < typename Tuple, template <typename...> auto What >
struct PutTupleInV;
template < typename... Types, template <typename...> auto What >
struct PutTupleInV<std::tuple<Types...>, What>
{
static constexpr auto value = What<Types...>;
};