Adapted from: What is the C ++ Base Enumeration Type? , The older C ++ standard specified in 7.2 / 5:
The main type of enumeration is an integral type, which can represent all the counter values defined in the enumeration. it is implementation-defined which integral type is used as the main type for the enumeration, except that the base type should not be greater than int if the value of the enumerator cannot int or unsigned int. If the list of enumerators is empty, the main type looks as if the enumeration had one enumerator with a value of 0. The value of sizeof () applied to the enumeration type is an object of the enumeration type or the enumerator is the value of the applied sizeof () to the base type.
From the nearest draft n4606 I could find 7.2 / 7 + 8, which reads:
7) For an enumeration whose base type is not fixed, the main type is an integral type that can represent all the counter values defined in the enumeration. If the integral type cannot represent all the values of the enumerator, the enumeration is poorly formed. it is implementation-defined which integral type is used as the main type, except that the base type should not be greater than int if the value of the enumerator cannot be placed in int or unsigned int. If the list of enumerations is empty, the base type looks as if the enumeration had a single enumerator with a value of 0.
8) For an enumeration whose base type is fixed, the enumeration values are the values of the base type. Otherwise, for an enumeration, where emin is the smallest counter and emax is the largest, enumeration values are values in the range from bmin to bmax, defined as follows: Let K - 1 for a two-component representation and 0 for a one addition or sign -value. bmax is the smallest value greater than or equal to max (| emin | - K, | emax |) and equal to 2M - 1, where M is a non-negative integer. bmin is zero if emin is non-negative and - (bmax + K) otherwise. The size is the smallest bit field large enough to hold all the values of the enumeration type - max (M, 1) if bmin is zero and M + 1 otherwise. It is possible to define an enumeration that has values not defined by any of its counters. If the enumeration list is empty, the enumeration value occurs as if the enumeration had one counter with a value of 0
On the one hand, this seems fairly close, on the other hand, the specific demand for the sizeof() operator has been removed. Nevertheless, I believe that it is safe enough to say that the answer to both questions is yes.
OriBS source share