What are the allowed types for an enum (class)?

user2746401

When declaring an enum (class) I can specify the underlying type that the enum will use, e.g.

enum class MyEnum : baseType { FIRST, SECOND };

What can baseType be? The usual choice would be uint32_t or something similar but could it also be float? Or even my own class?

TartanLlama

N4140 [dcl.enum]/2: [...] The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored. [...]

So baseType can be any integral type, i.e. bool, char, char16_t, char32_t, wchar_t and the signed and unsigned integer types.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

What happens if you static_cast invalid value to enum class?

From Java

What is the function of const specifier in enum types?

From Dev

Pattern for an enum-like class with many different types / constructors

From Dev

What protocols are allowed in hrefs in Swing's HTMLEditorKit class?

From Dev

What does the IntelliSense error "public data members are not allowed in non-value types" mean?

From Dev

What is Difference Comparing Class Types in Java

From Dev

Protected Variables aren't allowed by default in Checkstyle, but what about in an enum?

From Dev

What's the benefit of using enum embedded inside a class in JAVA?

From Dev

What is the reason define unknown enum in separate class?

From Dev

Putting enum types in different class

From Dev

Enum class members appearing as defined types not enum members

From Dev

Why is initialization of enum class temporaries with arbitrary values allowed?

From Dev

Restrict allowed httpMethods using enum

From Dev

Custom enum attribute gives error String types not allowed

From Dev

What is the difference between enum struct and enum class?

From Dev

What are the allowed Modes in Dynamics AX TextIO Class?

From Dev

What protocols are allowed in hrefs in Swing's HTMLEditorKit class?

From Dev

What are the expected values for the various "ENUM" types returned by the SurveyMonkey API?

From Dev

What's the benefit of using enum embedded inside a class in JAVA?

From Dev

Matlab optimization: what types of objective functions are 'allowed' with fminsearch.m and Co.?

From Dev

What is the reason define unknown enum in separate class?

From Dev

Putting enum types in different class

From Dev

Restrict allowed httpMethods using enum

From Dev

Buttonstyle - Dimension types not allowed

From Dev

How to have a parameter that is one of several enum types in a class

From Dev

What Swift property types are allowed in UIApperance compliant custom classes?

From Dev

What is the relation between class "type" and specific types?

From Dev

Error String types not allowed

From Dev

enum class: syntax details: types and generalities

Related Related

  1. 1

    What happens if you static_cast invalid value to enum class?

  2. 2

    What is the function of const specifier in enum types?

  3. 3

    Pattern for an enum-like class with many different types / constructors

  4. 4

    What protocols are allowed in hrefs in Swing's HTMLEditorKit class?

  5. 5

    What does the IntelliSense error "public data members are not allowed in non-value types" mean?

  6. 6

    What is Difference Comparing Class Types in Java

  7. 7

    Protected Variables aren't allowed by default in Checkstyle, but what about in an enum?

  8. 8

    What's the benefit of using enum embedded inside a class in JAVA?

  9. 9

    What is the reason define unknown enum in separate class?

  10. 10

    Putting enum types in different class

  11. 11

    Enum class members appearing as defined types not enum members

  12. 12

    Why is initialization of enum class temporaries with arbitrary values allowed?

  13. 13

    Restrict allowed httpMethods using enum

  14. 14

    Custom enum attribute gives error String types not allowed

  15. 15

    What is the difference between enum struct and enum class?

  16. 16

    What are the allowed Modes in Dynamics AX TextIO Class?

  17. 17

    What protocols are allowed in hrefs in Swing's HTMLEditorKit class?

  18. 18

    What are the expected values for the various "ENUM" types returned by the SurveyMonkey API?

  19. 19

    What's the benefit of using enum embedded inside a class in JAVA?

  20. 20

    Matlab optimization: what types of objective functions are 'allowed' with fminsearch.m and Co.?

  21. 21

    What is the reason define unknown enum in separate class?

  22. 22

    Putting enum types in different class

  23. 23

    Restrict allowed httpMethods using enum

  24. 24

    Buttonstyle - Dimension types not allowed

  25. 25

    How to have a parameter that is one of several enum types in a class

  26. 26

    What Swift property types are allowed in UIApperance compliant custom classes?

  27. 27

    What is the relation between class "type" and specific types?

  28. 28

    Error String types not allowed

  29. 29

    enum class: syntax details: types and generalities

HotTag

Archive