is it possible to check if T is a primary template?

Viewed 36

Is it somehow possible to check during compile time whether T is a primary template or a specialization? Expected usage:

template <typename>
struct foo{};

template <>
struct foo<double>{};

static_assert(is_primary_template<foo<int>>::value);
static_assert(!is_primary_template<foo<double>>::value);

It must yield true for a type instantiated from a primary template and false for template specialization.

I can't think of a way to implement this, rather with some workaround using type tags

template <typename T> 
using is_primary_template = std::is_base_of<primary_template, T>;
0 Answers
Related