Check if class is a template specialization? [duplicate]
Here's one where you can provide the template to be matched against :
template <class T, template <class...> class Template>
struct is_specialization : std::false_type {};
template <template <class...> class Template, class... Args>
struct is_specialization<Template<Args...>, Template> : std::true_type {};
static_assert(is_specialization<std::vector<int>, std::vector>{}, "");
static_assert(!is_specialization<std::vector<int>, std::list>{}, "");
CompareT
is a type and A
is a template. A class can't be a template, identically. A class can be a specialization of a template, so I'll assume that's what you want.
Partial specialization can do pattern-matching:
template<class T>
struct is_an_A // Default case, no pattern match
: std::false_type {};
template<class T>
struct is_an_A< A< T > > // For types matching the pattern A<T>
: std::true_type {};
template< class CompareT >
void compare() {
std::cout << is_an_A< CompareT >::value;
}