Not so good but showing some use case example
enum class MyType {
INT2,
INT4,
INT8,
FLOAT4,
FLOAT8
};
struct MyData {
void * data;
MyType type;
};
auto var1 = init_my_data(10, MyType::INT4);
auto var2 = init_my_data(10.23, MyType::FLOAT4);
auto switcher = overloaded{
[&]( magic_enum::enum_constant<MyType::INT4>, magic_enum::enum_constant<MyType::FLOAT4> ) {
float result = *static_cast<int*>(var1.data) + *static_cast<float*>(var2.data);
return init_my_type( result, MyType::FLOAT4 );
},
[]( auto, auto ) { throw notimplemented; }
};
enum_switch( switcher, var1.type, var2.type );
It's similar to what std::visit is doing with std::variant and cartesian product.
Right now I think you need to add enum_switch in enum_switch to achive it and that imo produces boilerplate code.
Not so good but showing some use case example
It's similar to what std::visit is doing with std::variant and cartesian product.
Right now I think you need to add enum_switch in enum_switch to achive it and that imo produces boilerplate code.