Reputation: 1175
This example code generates expected a class template, got std::pair <_T1, _T2>
. I tried using struct Struct <std::pair> {};
, but then parameters T
and M
become undeducible. How to avoid this?
template <template <class...> class>
struct Struct {};
template <class T, class M>
struct Struct <std::pair <T, M>> {};
Upvotes: 3
Views: 2205
Reputation: 217075
Depending of what you want
template <template <class...> class>
struct Struct {};
template <>
struct Struct <std::pair>
{
// Specialization
};
or
template <typename> struct Struct {};
template <typename First, typename Second>
struct Struct <std::pair<First, Second>>
{
// Specialization
};
Upvotes: 4
Reputation: 6086
That is not a valid specialization for your template.
The reason why is because std::pair<T, M>
is a full specialization of the class template std::pair
and therefore a class. Your template expects a class template parameter which is exactly what the compiler is telling you.
Upvotes: 2