mardi 8 décembre 2015

Static assert template parameter check while creating an alias

Let's say we have the structure where I need to check the types of template parameters (wchar_t is just an example):

template <typename T>
struct Foo {
    static_assert(std::is_same<T, wchar_t>::value, "Failure");
}

Of course following code will not compile:

Foo<int> foo;

But how can I prevent from compiling:

using foo = Foo<int>;

?

Aucun commentaire:

Enregistrer un commentaire