Keyword for both types and integrals for parameter packs

Viewed 42

If I have a trait that detects a specialisation (i.e. a templated type):

template <typename T>
struct is_specialisation : std::false_type {
};

template <template <typename...> class U, typename... Args>
struct is_specialisation<U<Args...>> : std::true_type {
};

This works as expected:

traits::is_specialisation<std::vector<int>>::value;              // True
traits::is_specialisation<std::string_view>::value;              // True
traits::is_specialisation<std::tuple<char, int, double>>::value; // True
traits::is_specialisation<float>::value;                         // False

Except when one of the parameter pack types is actually a value:

traits::is_specialisation<std::array<char, 4>>::value;  // False

This is because the template <typename...> class U declaration is specifically for types, if I switched it to template <auto...> class U it would accept all values - but is there a way of declaring such it can take a mixture of types and values?

0 Answers
Related