Reputation: 965
I would like to ask if it is possible to insert static assert into template parameters.
Let´s say I want to create class StaticArray<T,N>
and I want to make it impossible for users to instantiate this class with size equal to 0. Is there any way to insert something like static_assert(N != 0, "error message")
into my class?
Upvotes: 0
Views: 2050
Reputation: 48447
template <typename T, std::size_t N>
class StaticArray
{
static_assert(N != 0, "error message");
};
Upvotes: 6