Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reflect to enum with type and value strings? #107

Open
WorstCodeWay opened this issue Mar 14, 2022 · 4 comments
Open

How to reflect to enum with type and value strings? #107

WorstCodeWay opened this issue Mar 14, 2022 · 4 comments

Comments

@WorstCodeWay
Copy link

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?

@aantron
Copy link
Owner

aantron commented Mar 14, 2022

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.

@WorstCodeWay
Copy link
Author

WorstCodeWay commented Mar 14, 2022

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

Would you be kindly tell me how to do this?

@aantron
Copy link
Owner

aantron commented Mar 14, 2022

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.

@WorstCodeWay
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants