-
Notifications
You must be signed in to change notification settings - Fork 23
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
How to represent: enum class X : int;? Possibly add opt<Type> underlying_type #22
Comments
Enums are an odd case compared to class types. An enum declaration with an underlying type is really a complete type, where as there a forward declaration of a class references an incomplete type. So, the issue here is whether a |
One of the ideas we had during recent discussion about this issue was to introduce a meta type, tentative name, [Complete type: enum, alignment: x, size: sizeof(int)] that will be used in this case instead of lexicon::enum_type() both in a Typedecl when there is no initializer (i.e. enum body) and as a type of ipr::Enum itself. enum class X : int;
enum class X : int { a, b }; Will be represented as:
|
We talked a bit more about this representation. Latest thinking:
This addresses a use case: enum class X;
using undy = std::underlying_type_t<X>; Now std::underlying_type_t can grab the type from the layout field.
enum class X;
enum X; // error: scoped enum cannot be redeclared as an unscoped one The suggestion is to introduce a new metatype scoped_enum_type to the lexicon that will be the type of scoped enumerations and the enum_type will be used for unscoped ones. |
There are two issues in this report:
All of these issues stem from timeline: when IPR was originally designed, the notion of separately specifying the underlying type of an enumeration was not yet a thing. This points to the perilous task of predicting the future. Aspect (1) bears some similarity with base class types of a class declaration. |
Provide accessor for the underlying type of an enumeration. Partially addresses #22 .
Provide accessor for the underlying type of an enumeration. Partially addresses #22 .
Need to be able to represent:
enum class X : int;
Currently not representable by IPR
Enum should have opt underlying_type
The text was updated successfully, but these errors were encountered: