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
16 The semantics of initializers are as follows.The destination type is the type of the object or reference being initialized
Now the Note:
2 [Note 2: Expressions with a given type will be implicitly converted to other types in several contexts:
(2.1) When used as operands of operators. The operator's requirements for its operands dictate the destination type ([expr.compound]). (2.2) When used in the condition of an if statement ([stmt.if]) or iteration statement ([stmt.iter]). The destination type is bool. (2.3) When used in the expression of a switch statement ([stmt.switch]). The destination type is integral. (2.4) When used as the source expression for an initialization (which includes use as an argument in a function call and use as the expression in a return statement).
The type of the entity being initialized is (generally) the destination type. See [dcl.init], [dcl.init.ref].
— end note]
The operator's requirements for its operands dictate the destination type
is wrong, because a built-in operator's operand is not an «object or reference being initialized»
(2.2) is kinda OK, because implicit conversion to bool is modeled as declaration bool t(E);
As we know,
Now the Note:
is wrong, because a built-in operator's operand is not an «object or reference being initialized»
(2.2) is kinda OK, because implicit conversion to
bool
is modeled as declarationbool t(E);
(2.3) is wrong. Class types are contextually implicitly converted (http://eel.is/c++draft/stmt.switch#2.sentence-3), and this conversion is described not relying on initialization http://eel.is/c++draft/conv.general#def:contextually_implicitly_converted
(2.4) is, obviously, OK
The text was updated successfully, but these errors were encountered: