I have tried to use this suggestion to do a static assert, but I do not get a compilation error if I use it within a method of a template.
The example follows :
int foo(const int k)
{
STATIC_ASSERT( k > 9, error_msg );
return k+5;
}
Static assertions only work with compile-time constant expressions.
k is not a compile-time constant expression.
Non-type template parameters are compile-time constant expressions during template instantiation, so you could adapt your code thus:
template
int foo()
{
STATIC_ASSERT( K > 9, error_msg );
return K+5;
}