-
Notifications
You must be signed in to change notification settings - Fork 260
[BUG] Function overloading with an @enum type produces unexpected results #687
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
Comments
This was hinted at #131 (comment). |
This formulation seems to permit having seemingly struct perms {
unsigned underlying;
static const perms read;
};
constexpr perms perms::read = {1};
static_assert(perms::read.underlying == 1);
#include <type_traits>
static_assert(std::integral_constant<perms, perms::read>{}.value.underlying == 1); |
Thanks, I understand the underlying issue now. Still, I hope that the ergonomics can be improved. I think the new @enum fails to adhere to the principle of least astonishment. |
Emitting object aliases at type-scope like above at #687 (comment) But it would also makes all other uses of them in the signatures of members impossible. |
Right. I agree that using enums in signatures is a desirable feature. Anyway, I will close this bug since it is not really a bug, but more like a design tradeoff. |
I view it as a bug that the enumerator doesn't have the type of the enumeration. |
Although there'd be more resistance to migrating to Cpp2's |
Ack: Yes, I'm looking at this now. I always intended for enumerators to have the type of the enumeration, but Cpp1 doesn't allow that, so the initial implementation worked around it. The solution I'm currently pursuing is to lower all type-scope object aliases as you suggest (see also https://stackoverflow.com/questions/11928089/), and then enumerators would Just Work too. That way I don't need to make enumerations a special case. |
I've now improved this in b589f5d
Thanks! |
Describe the bug
Function overloading with an @enum type produces unexpected results.
To Reproduce
Try the following code:
After running this program, I'd expect to see the following on stdout:
Instead, the generic function is called:
The text was updated successfully, but these errors were encountered: