I have an enum like:
enum E
{
TYPE_FLOAT,
TYPE_CHAR,
TYPE_INT
}
And I want to create a compile-time mapping to get the appropri
Maybe because you forgot to put a semicolon after the enum definition, this works for me in LiveWorkSpace:
#include
enum E
{
TYPE_FLOAT,
TYPE_CHAR,
TYPE_INT
} ;
template struct GetE;
template<> struct GetE { static constexpr E type = TYPE_FLOAT; };
template<> struct GetE { static constexpr E type = TYPE_CHAR; };
template<> struct GetE { static constexpr E type = TYPE_INT; };
int main()
{
std::cout << GetE::type << std::endl ;
}
here is a link to the code http://liveworkspace.org/code/nHqUe$6