Can we detect member function template, variable template, class/struct/union template or alias templ
In C++14, you can use template variables to detect if a type is a specialization:
#include
template
constexpr bool is_spec = false;
template class T, typename... U>
constexpr bool is_spec> = true;
struct S {};
template struct R {};
int main() {
static_assert(not is_spec, "!");
static_assert(is_spec>, "!");
}
Note that it won't work if non-type parameters are involved (as an example template).