On Mon, 10 Jul 2023 at 10:08, Sebastian Wittmeier via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

Hi Alex,

I think you misunderstood.

Jonathan's INT_MIN / INT_MAX do not return 1 or 16, respectively, for enums.

Quite the opposite, Jonathan pointed out that the existing values INT_MIN / INT_MAX can be stored in MyEnum, so 1 or 16 are _not_ the minimum or maximum possible value for the example.


Precisely. Any proposal related to the "min" and "max" of enums needs to discuss the valid values of the enumeration type.
 

 

This has often used practical applications:

MyEnum wolpertinger = eMonkey | eFish | eGoat | eFrog; // 30 > 16

 

e.g. if like in the example the enum values are given as power of 2 flags, which can be added/ORed.


Yup. I don't see why you would define power of two enumerators unless you intend their bitwise OR to be valid, which will produce a higher value than the "max" (although the bitwise OR of all the enumerators uses the same number of bits as the highest enumerator). So the example in the "proposal" isn't even self-consistent IMHO.