-
Notifications
You must be signed in to change notification settings - Fork 142
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
Using enum type as the key for enum values of a struct #1117
Comments
If you namespace your struct MyType {
int x{};
int y{};
::MyEnum MyEnum{MyEnum::First};
}; Now your type can be reflected and has the name you want. Here is an example on compiler explorer: https://gcc.godbolt.org/z/T4WrhK7o3 Of course, you may not want this name in C++, in which case you will have to use your current solution. |
Thank you for the response. That solution still requires to manually type-in the matching identifier as a member variable of |
This is a cool idea, and I'll keep this issue open as I consider it more. This would be another compile time option to enable, which would prevent the overhead of checking for the enum at compile time if the option wasn't enabled. |
For more context, I have created this on Compiler Explorer. The current output is:
But what I would ideally like is to remove the leading
The motivation behind this feature is to be able to obtain some app context from the user in json format then the |
The piece of code below does exactly what I want. However, I want to streamline the process of constructing
MyType::glaze::value
so that I do not have to enumerate all the pointers to the members as I have done here. Is it possible? Thanks.The text was updated successfully, but these errors were encountered: