You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A value of integral or enumeration type can be explicitly converted to a complete enumeration type. If the enumeration type has a fixed underlying type, the value is first converted to that type by integral promotion ([conv.prom]) or integral conversion ([conv.integral]), if necessary, and then to the enumeration type.
Consider this example
enumclassDestination: int{};
char c = 0;
auto t = (Destination)c;
The enumeration type Destination has a fixed type that is int, while the source is of type char. According to the above rule, the prvalue of type char is firstly converted to int with an integral promotion, we get a middle prvalue of type int, then convert it to the enumeration type Destination. How does a prvalue of integer type(i.e. int) convert to the enumeration type Destination? There is no standard conversion that specifies such an effect:
Destination v = 0;
The same issue is also in
A value of floating-point type can also be explicitly converted to an enumeration type. The resulting value is the same as converting the original value to the underlying type of the enumeration ([conv.fpint]), and subsequently to the enumeration type.
we do not specify how to convert a value of the underlying type of the enumeration E to type E, or to say that such a conversion would circularly depend on [expr.static.cast] p10. We even do not know whether convert to means explicitly convert to or implicitly convert to for converting the middle result to the final.
The text was updated successfully, but these errors were encountered:
[expr.static.cast] p10 says
Consider this example
The enumeration type
Destination
has a fixed type that isint
, while the source is of typechar
. According to the above rule, the prvalue of typechar
is firstly converted toint
with an integral promotion, we get a middle prvalue of typeint
, then convert it to the enumeration typeDestination
. How does a prvalue of integer type(i.e.int
) convert to the enumeration typeDestination
? There is no standard conversion that specifies such an effect:Destination v = 0;
The same issue is also in
we do not specify how to convert a value of the underlying type of the enumeration
E
to typeE
, or to say that such a conversion would circularly depend on [expr.static.cast] p10. We even do not know whetherconvert to
meansexplicitly convert to
orimplicitly convert to
for converting the middle result to the final.The text was updated successfully, but these errors were encountered: