Hi,
I've written some code which compiles as I want it to with MSVC 10 but I need the same code to compile with Clang too.
Basically I have a template helper function, but I want users to use the specialisations only. If they try to use the non specialised template function a static_assert triggers. It looks like this:
template< typename T >
T GetValue( const Variant& variant )
{
static_assert(0, "GetValue requires a template specialisation for 'T'");
}
template<> float GetValue(const Variant& variant)
{
return (float)variant.GetDouble();
}
template<> int GetValue(const Variant& variant)
{
return (int)variant.GetInt();
}
template<> bool GetValue(const Variant& variant)
{
return variant.GetBool();
}
MSVC happily ignores the static_assert, but I'm finding that it's firing in Clang. Any clever ideas on how I can avoid that?