-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Same value leads to wrong _to_string method #84
Comments
If the enum at runtime is still represented as an integer value (rather than an index into the enum declaration or otherwise), I don't think there is a way for |
What about an "Indexed" enum version with a limited/different feature set? |
It's possible to create it as a variant, but it would be a different library. The direct representation is one of the "features" of this library (and typical enums in C++ and similar languages). It allows direct usage in reading/writing data formats, for example. |
Okay. Thanks for you quick feedback. |
Hi,
there seems to be a problem when assigning the same integer value to two different enum values. The
_to_string()
method will then print the name of the first enum value this integer was assigned to.Example:
Godbolt
This may seem weird but is explicitly allowed by the C99 standard WG14/N1256 6.7.2.2/3.
Sorry if I missed this as known behavior somewhere, I only found a short reference to it in the FAQ related to the use of indices for representation.
From your FAQ
This is unfortunately true for the current implementation as well, even though in a different way than you're talking about in the FAQ.
I can see why it's implemented this way but is there a possibility of maybe having a "slower" or less "smart" enum with a pretty much equal interface that can solve this?
The text was updated successfully, but these errors were encountered: