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
Scoped enums (enum class) fix several problems with traditional, unscoped enums. Most notably
They do not implicitly convert to or from integer types
They do not pollute the parent namespace with their constants by default
I notice the compiler currently hacks around the second issue with unscoped enums by defining a namespace for the enum. However, in my opinion, (1) is still worth addressing and it would be nice to have slightly cleaner generated headers.
Given that changing all enums to scoped enums would break existing code, I would suggest adding a flag for this behaviour when compiling C++, such as --scoped-enum.
The text was updated successfully, but these errors were encountered:
https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations
Scoped enums (
enum class
) fix several problems with traditional, unscoped enums. Most notablyI notice the compiler currently hacks around the second issue with unscoped enums by defining a namespace for the enum. However, in my opinion, (1) is still worth addressing and it would be nice to have slightly cleaner generated headers.
Given that changing all enums to scoped enums would break existing code, I would suggest adding a flag for this behaviour when compiling C++, such as
--scoped-enum
.The text was updated successfully, but these errors were encountered: