
On 12 Jun 2025 18:56, Peter Dimov via Boost wrote:
Andrey Semashev wrote:
The standard defines enumerations as "a distinct type with named constants". That is, its a way to define a number of named constants and associate them with a type. The standard then goes on to say that an enumeration has an underlying type. It doesn't say that the set of values of the enum type is limited to the named constants (as it says e.g. for bool); other values, as long as those values are representable by the underlying type, are implicitly allowed.
Not quite. For scoped enums, and those with fixed underlying type, all values of the underlying type is allowed. For "normal" enums, it's a bit more complex; the minimum number of bits that can represent all enumerators is computed, and values that fit into this number of bits are allowed.
So any bitwise combination of enumerators is allowed, but negation may not be.
Yes, thank you for the correction.