When putting a with a hardcoded value, it is triggered even if the function it's in isn't instantiated. Is this behavior correct or do I misunderstand how static assert works?
#include <type_traits>
template <class T>
struct Helper
{
static void do_something()
{
// Always fails, even when not instantiated.
static_assert(false,
"You must specialize this class to serialize Enums.");
// Work around:
static_assert(!std::is_same<T, T>::value,
"You must specialize this class to serialize Enums.");
}
};
Using: g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1