I have something like:
struct A { ... };
struct B { ... };
struct C { ... };
class MyEnum {
public:
enum Value { a, b, c; }
}
template
The multiple definitions are because you need to either add the inline
keyword or push the implementation of your specializations into a cpp file, leaving only the declarations of such in the header.
You could probably use mpl::map to write a sort-of generic version. Something like so:
struct A {};
struct B {};
struct C {};
enum Value { a,b,c };
template < typename T >
Value get_value()
{
using namespace boost::mpl;
typedef mpl::map
<
mpl::pair< A, mpl::int_ >
, mpl::pair< B, mpl::int_ >
, mpl::pair< C, mpl::int_ >
> type_enum_map;
typedef typename mpl::at::type enum_wrap_type;
return static_cast(enum_wrap_type::value);
}