better-enums icon indicating copy to clipboard operation
better-enums copied to clipboard

How to reflect to enum with type and value strings?

Open WorstCodeWay opened this issue 2 years ago • 4 comments

Hi, this is a great work you’v made. But how to reflect from strings of enum value and name?

I have,

enum Type
{
   A = 1,
   B = 2
};

and text content

enum name : Type ; value: A

How to reflect the strings into Type with A?

I know there is no reflection in c++, but can we build that system just with help of this better-enum project?

WorstCodeWay avatar Mar 14 '22 11:03 WorstCodeWay

You would have to edit the macro to store the name of the type being declared somewhere. I'm not immediately sure if it can be done in a compile-time only way. It can definitely be done with an ordinary run-time map.

aantron avatar Mar 14 '22 12:03 aantron

It can definitely be done with an ordinary run-time map.

Would you be kindly tell me how to do this?

WorstCodeWay avatar Mar 14 '22 13:03 WorstCodeWay

This question is far too generic and contains no information at all about what specifically you might be having trouble with.

I won't have time in the immediate term to offer anything except very specific advice to very specific prompts with specific technical issues and information.

aantron avatar Mar 14 '22 13:03 aantron

This question is far too generic and contains no information at all about what specifically you might be having trouble with.

I won't have time in the immediate term to offer anything except very specific advice to very specific prompts with specific technical issues and information.

Thanks anyway. BTW, great work again!

WorstCodeWay avatar Mar 14 '22 14:03 WorstCodeWay