You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realize you may not be maintaining this library currently, but I may have found a bug, and I'd be remiss in not sharing the information.
It seems the Meta Enum member values may not be correct if an enumerant is initialized using the value of a previous enumerant. Here's a self-contained example:
I think the issue is in the 'Type##_internal_size' function. With this approach, the int wrapper for 'b' is empty, and when the int wrapper for 'c' is created, it's empty too. So the method being used there doesn't seem to be able to account for assignment from previous enumerants (unless I'm mistaken).
I stumbled across this while trying some different enum libraries and doing some experimenting of my own. If I manage to solve this particular problem in my own code, I'll try to post back.
The text was updated successfully, but these errors were encountered:
I'll offer one more comment here with a few additional observations.
It might be that there are more issues related to initialization apart from what I mentioned above. For example, this works:
enumclassEnum : int { a, b, c = []() { return b; }(), d };
But this:
meta_enum_class(Enum, int, a, b, c = []() { return b; }(), d);
Fails because the lambda doesn't capture 'b' in 'Type##_internal_size'.
To further complicate matters, you can do this:
enumclassEnum : int { a [[maybe_unused]], b, c, d };
But not this:
meta_enum_class(Enum, int, a [[maybe_unused]], b, c, d);
Perhaps there are solutions here, but maybe there are just some limitations to this particular approach.
Edit: Let me add that I don't mean to imply these are faults with the library. These seem like difficult problems to solve (especially without making extensive use of the preprocessor). And, the only one of these issues that's likely to come up in practice would be simple initialization from previous enumerants, e.g. 'c = b + 2'. The other issues (lambdas, attributes) are more just curiosities.
I realize you may not be maintaining this library currently, but I may have found a bug, and I'd be remiss in not sharing the information.
It seems the Meta Enum member values may not be correct if an enumerant is initialized using the value of a previous enumerant. Here's a self-contained example:
Output:
I think the issue is in the 'Type##_internal_size' function. With this approach, the int wrapper for 'b' is empty, and when the int wrapper for 'c' is created, it's empty too. So the method being used there doesn't seem to be able to account for assignment from previous enumerants (unless I'm mistaken).
I stumbled across this while trying some different enum libraries and doing some experimenting of my own. If I manage to solve this particular problem in my own code, I'll try to post back.
The text was updated successfully, but these errors were encountered: