[conv.prom] (original) (raw)
7 Expressions [expr]
7.3 Standard conversions [conv]
7.3.7 Integral promotions [conv.prom]
For the purposes of [conv.prom], a converted bit-field is a prvalue that is the result of an lvalue-to-rvalue conversion ([conv.lval]) applied to a bit-field ([class.bit]).
A prvalue that is not a converted bit-field and has an integer type other thanbool, char8_t, char16_t,char32_t, or wchar_t whose integer conversion rank ([conv.rank]) is less than the rank of int can be converted to a prvalue of type int if int can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type unsigned int.
A prvalue of an unscoped enumeration type whose underlying type is not fixed can be converted to a prvalue of the first of the following types that can represent all the values of the enumeration ([dcl.enum]): int,unsigned int, long int, unsigned long int,long long int, or unsigned long long int.
If none of the types in that list can represent all the values of the enumeration, a prvalue of an unscoped enumeration type can be converted to a prvalue of the extended integer type with lowest integer conversion rank ([conv.rank]) greater than the rank of long longin which all the values of the enumeration can be represented.
If there are two such extended types, the signed one is chosen.
A prvalue of an unscoped enumeration type whose underlying type is fixed ([dcl.enum]) can be converted to a prvalue of its underlying type.
Moreover, if integral promotion can be applied to its underlying type, a prvalue of an unscoped enumeration type whose underlying type is fixed can also be converted to a prvalue of the promoted underlying type.
[Note 1:
A converted bit-field of enumeration type is treated as any other value of that type for promotion purposes.
— _end note_]
A converted bit-field of integral type can be converted to a prvalue of type int if int can represent all the values of the bit-field; otherwise, it can be converted tounsigned int if unsigned int can represent all the values of the bit-field.
A prvalue of typechar8_t, char16_t, char32_t, orwchar_t ([basic.fundamental]) (including a converted bit-field that was not already promoted to int or unsigned intaccording to the rules above) can be converted to a prvalue of the first of the following types that can represent all the values of its underlying type:int,unsigned int,long int,unsigned long int,long long int,unsigned long long int, or its underlying type.
A prvalue of type bool can be converted to a prvalue of typeint, with false becoming zero and true becoming one.
These conversions are called integral promotions.