|
|
|
|
Both scoped enumeration types and unscoped enumeration types whose underlying type is fixed can be initialized from an integer without a cast, using list initialization, if all of the following is true: . the initialization is direct-list-initialization . the initializer list has only a single element . the enumeration is either scoped or unscoped with underlying type fixed . the conversion is non-narrowing This makes it possible to introduce new integer types (e.g. SafeInt) that enjoy the same existing calling conventions as their underlying integer types, even on ABIs that penalize passing/returning structures by value. https://en.cppreference.com/w/cpp/language/enum |
enum class colour_1 { RED, GREEN, BLUE };
.enum colour_2 { RED, GREEN, BLUE };
.