-
Notifications
You must be signed in to change notification settings - Fork 329
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
Add variable definition for enum types #445
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks useful to me!
I like this approach. A getter would be nice too, so we could use it for retrieving property values. Currently we set all enums using int as the type on properties, not sure if this could cause any issues. I hope the library-wide formatting I decided to do isn't causing you too much trouble here. At least now you should be able to enable "format on save" if you have clang-format enabled on your editor. There is also a large file here I don't think you intended to add. |
oops yeah the compilation database.. |
I actually dont know what the best way for a setter would be, i dont want to be too invasive in the variant type. do you have an idea for it? |
I think your solution there already is good. Maybe, to be more generic, cast it to a specific integer type (int64_t?) before storing. Otherwise, if we don't support a specific underlying type, I suspect it won't compile. static_assert the size to be sure it fits in the int64_t. I think this should be safe? Did you mean the getter? I think the same principle, we would need an SFINAE for GetInto enums. Maybe it is a good idea to measure compile times before and after this change :) |
I worked around it using reinterpret_cast, not sure if thats a good idea though. |
I'm worried about using the type converter, because every time we use a new enum, there will be new type converter function invoked for each one of the other types in I drafted something, partly based on your solution, for what I am thinking here: 7f34305 Just a small FYI, |
True thats a good point. Thanks for sharing your solution, i kinda figured using a temporary value for the GetInto function would be a version that could work. Think we can just use your version then |
Alright, sounds good. Do you want to integrate that solution into your other changes here? |
Co-authored-by: Dakror <mail@dakror.de>
I wanted a few more changes and just went ahead and committed them, hope that's okay. If you are happy with this then I am ready to merge it. |
looks good to me |
Alright, thanks again for the PR. |
I got tired of having to register custom getter and setters for every enum type i have in my structs, so i made this small utility change using std::underlying_type