I have something like:
struct A { ... };
struct B { ... };
struct C { ... };
class MyEnum {
public:
enum Value { a, b, c; }
}
template
You can map types to enums at compile time:
#include
struct A { int n; };
struct B { double f; };
struct C { char c; };
class MyEnum
{
public:
enum Value { a, b, c };
};
template struct StructToMyEnum {};
template<> struct StructToMyEnum {enum {Value = MyEnum::a};};
template<> struct StructToMyEnum {enum {Value = MyEnum::b};};
template<> struct StructToMyEnum {enum {Value = MyEnum::c};};
int main (int argc, char* argv[])
{
std::cout << "A=" << StructToMyEnum::Value << std::endl;
return 0;
}