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 :
This is basically Maxim's answer with a little more convenient interface. I have taken it from here. Nice thing about it is that the use of templates prevents the user from passing a non-compile-time-constant value as the condition.
template
struct Static_assert_cpp98
{
static void apply() {static const char junk[ Is_Condition_Met ? 1 : -1 ];}
};
template<>
struct Static_assert_cpp98
{
static void apply() {}
};
#define STATIC_ASSERT_CPP98(condition) Static_assert_cpp98::apply()