lets say I have this simplified example:
I have some code that does serialization and deserialization of a class...
first byte is enum that encodes class type(they all inherit from same base)..
eg.
Color* c;
auto classType == read_byte(buffer);
switch (classType)
case eBlue:
{
c = new Blue(buffer);
}
case eGray:
{
c = new Gray(buffer)
}
//...
is there any way to have a map from enum to type so I can replace switch
c = new enum2Type(buffer);
edit ofc I would never use raw ptr IRL.:)
std::map<TheEnumType, std::function<Color*(TheBufferType)>?