From Jason Turner

[expr.compound]

Large diff (124.9 KB) - rendering may be slow on some devices

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphx1at_bo/{from.md → to.md} +2880 -0
tmp/tmphx1at_bo/{from.md → to.md} RENAMED
@@ -0,0 +1,2880 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Compound expressions <a id="expr.compound">[[expr.compound]]</a>
2
+
3
+ ### Postfix expressions <a id="expr.post">[[expr.post]]</a>
4
+
5
+ Postfix expressions group left-to-right.
6
+
7
+ ``` bnf
8
+ postfix-expression:
9
+ primary-expression
10
+ postfix-expression '[' expr-or-braced-init-list ']'
11
+ postfix-expression '(' expression-listₒₚₜ ')'
12
+ simple-type-specifier '(' expression-listₒₚₜ ')'
13
+ typename-specifier '(' expression-listₒₚₜ ')'
14
+ simple-type-specifier braced-init-list
15
+ typename-specifier braced-init-list
16
+ postfix-expression '.' 'template'ₒₚₜ id-expression
17
+ postfix-expression '->' 'template'ₒₚₜ id-expression
18
+ postfix-expression '++'
19
+ postfix-expression '-{-}'
20
+ dynamic_cast '<' type-id '>' '(' expression ')'
21
+ static_cast '<' type-id '>' '(' expression ')'
22
+ reinterpret_cast '<' type-id '>' '(' expression ')'
23
+ const_cast '<' type-id '>' '(' expression ')'
24
+ typeid '(' expression ')'
25
+ typeid '(' type-id ')'
26
+ ```
27
+
28
+ ``` bnf
29
+ expression-list:
30
+ initializer-list
31
+ ```
32
+
33
+ [*Note 1*: The `>` token following the *type-id* in a `dynamic_cast`,
34
+ `static_cast`, `reinterpret_cast`, or `const_cast` may be the product of
35
+ replacing a `>{>}` token by two consecutive `>` tokens
36
+ [[temp.names]]. — *end note*]
37
+
38
+ #### Subscripting <a id="expr.sub">[[expr.sub]]</a>
39
+
40
+ A postfix expression followed by an expression in square brackets is a
41
+ postfix expression. One of the expressions shall be a glvalue of type
42
+ “array of `T`” or a prvalue of type “pointer to `T`” and the other shall
43
+ be a prvalue of unscoped enumeration or integral type. The result is of
44
+ type “`T`”. The type “`T`” shall be a completely-defined object
45
+ type.[^11] The expression `E1[E2]` is identical (by definition) to
46
+ `*((E1)+(E2))`, except that in the case of an array operand, the result
47
+ is an lvalue if that operand is an lvalue and an xvalue otherwise. The
48
+ expression `E1` is sequenced before the expression `E2`.
49
+
50
+ [*Note 1*: A comma expression [[expr.comma]] appearing as the
51
+ *expr-or-braced-init-list* of a subscripting expression is deprecated;
52
+ see [[depr.comma.subscript]]. — *end note*]
53
+
54
+ [*Note 2*: Despite its asymmetric appearance, subscripting is a
55
+ commutative operation except for sequencing. See  [[expr.unary]] and 
56
+ [[expr.add]] for details of `*` and `+` and  [[dcl.array]] for details
57
+ of array types. — *end note*]
58
+
59
+ A *braced-init-list* shall not be used with the built-in subscript
60
+ operator.
61
+
62
+ #### Function call <a id="expr.call">[[expr.call]]</a>
63
+
64
+ A function call is a postfix expression followed by parentheses
65
+ containing a possibly empty, comma-separated list of
66
+ *initializer-clause*s which constitute the arguments to the function.
67
+
68
+ [*Note 1*: If the postfix expression is a function or member function
69
+ name, the appropriate function and the validity of the call are
70
+ determined according to the rules in  [[over.match]]. — *end note*]
71
+
72
+ The postfix expression shall have function type or function pointer
73
+ type. For a call to a non-member function or to a static member
74
+ function, the postfix expression shall either be an lvalue that refers
75
+ to a function (in which case the function-to-pointer standard conversion
76
+ [[conv.func]] is suppressed on the postfix expression), or have function
77
+ pointer type.
78
+
79
+ For a call to a non-static member function, the postfix expression shall
80
+ be an implicit ([[class.mfct.non-static]], [[class.static]]) or
81
+ explicit class member access [[expr.ref]] whose *id-expression* is a
82
+ function member name, or a pointer-to-member expression
83
+ [[expr.mptr.oper]] selecting a function member; the call is as a member
84
+ of the class object referred to by the object expression. In the case of
85
+ an implicit class member access, the implied object is the one pointed
86
+ to by `this`.
87
+
88
+ [*Note 2*: A member function call of the form `f()` is interpreted as
89
+ `(*this).f()` (see  [[class.mfct.non-static]]). — *end note*]
90
+
91
+ If the selected function is non-virtual, or if the *id-expression* in
92
+ the class member access expression is a *qualified-id*, that function is
93
+ called. Otherwise, its final overrider [[class.virtual]] in the dynamic
94
+ type of the object expression is called; such a call is referred to as a
95
+ *virtual function call*.
96
+
97
+ [*Note 3*: The dynamic type is the type of the object referred to by
98
+ the current value of the object expression. [[class.cdtor]] describes
99
+ the behavior of virtual function calls when the object expression refers
100
+ to an object under construction or destruction. — *end note*]
101
+
102
+ [*Note 4*: If a function or member function name is used, and name
103
+ lookup [[basic.lookup]] does not find a declaration of that name, the
104
+ program is ill-formed. No function is implicitly declared by such a
105
+ call. — *end note*]
106
+
107
+ If the *postfix-expression* names a destructor or pseudo-destructor
108
+ [[expr.prim.id.dtor]], the type of the function call expression is
109
+ `void`; otherwise, the type of the function call expression is the
110
+ return type of the statically chosen function (i.e., ignoring the
111
+ `virtual` keyword), even if the type of the function actually called is
112
+ different. This return type shall be an object type, a reference type or
113
+ cv `void`. If the *postfix-expression* names a pseudo-destructor (in
114
+ which case the *postfix-expression* is a possibly-parenthesized class
115
+ member access), the function call destroys the object of scalar type
116
+ denoted by the object expression of the class member access (
117
+ [[expr.ref]], [[basic.life]]).
118
+
119
+ Calling a function through an expression whose function type is
120
+ different from the function type of the called function’s definition
121
+ results in undefined behavior.
122
+
123
+ When a function is called, each parameter [[dcl.fct]] is initialized (
124
+ [[dcl.init]], [[class.copy.ctor]]) with its corresponding argument. If
125
+ there is no corresponding argument, the default argument for the
126
+ parameter is used.
127
+
128
+ [*Example 1*:
129
+
130
+ ``` cpp
131
+ template<typename ...T> int f(int n = 0, T ...t);
132
+ int x = f<int>(); // error: no argument for second function parameter
133
+ ```
134
+
135
+ — *end example*]
136
+
137
+ If the function is a non-static member function, the `this` parameter of
138
+ the function [[class.this]] is initialized with a pointer to the object
139
+ of the call, converted as if by an explicit type conversion
140
+ [[expr.cast]].
141
+
142
+ [*Note 5*: There is no access or ambiguity checking on this conversion;
143
+ the access checking and disambiguation are done as part of the (possibly
144
+ implicit) class member access operator. See  [[class.member.lookup]],
145
+ [[class.access.base]], and  [[expr.ref]]. — *end note*]
146
+
147
+ When a function is called, the type of any parameter shall not be a
148
+ class type that is either incomplete or abstract.
149
+
150
+ [*Note 6*: This still allows a parameter to be a pointer or reference
151
+ to such a type. However, it prevents a passed-by-value parameter to have
152
+ an incomplete or abstract class type. — *end note*]
153
+
154
+ It is *implementation-defined* whether the lifetime of a parameter ends
155
+ when the function in which it is defined returns or at the end of the
156
+ enclosing full-expression. The initialization and destruction of each
157
+ parameter occurs within the context of the calling function.
158
+
159
+ [*Example 2*: The access of the constructor, conversion functions or
160
+ destructor is checked at the point of call in the calling function. If a
161
+ constructor or destructor for a function parameter throws an exception,
162
+ the search for a handler starts in the scope of the calling function; in
163
+ particular, if the function called has a *function-try-block*
164
+ [[except.pre]] with a handler that could handle the exception, this
165
+ handler is not considered. — *end example*]
166
+
167
+ The *postfix-expression* is sequenced before each *expression* in the
168
+ *expression-list* and any default argument. The initialization of a
169
+ parameter, including every associated value computation and side effect,
170
+ is indeterminately sequenced with respect to that of any other
171
+ parameter.
172
+
173
+ [*Note 7*: All side effects of argument evaluations are sequenced
174
+ before the function is entered (see 
175
+ [[intro.execution]]). — *end note*]
176
+
177
+ [*Example 3*:
178
+
179
+ ``` cpp
180
+ void f() {
181
+ std::string s = "but I have heard it works even if you don't believe in it";
182
+ s.replace(0, 4, "").replace(s.find("even"), 4, "only").replace(s.find(" don't"), 6, "");
183
+ assert(s == "I have heard it works only if you believe in it"); // OK
184
+ }
185
+ ```
186
+
187
+ — *end example*]
188
+
189
+ [*Note 8*: If an operator function is invoked using operator notation,
190
+ argument evaluation is sequenced as specified for the built-in operator;
191
+ see  [[over.match.oper]]. — *end note*]
192
+
193
+ [*Example 4*:
194
+
195
+ ``` cpp
196
+ struct S {
197
+ S(int);
198
+ };
199
+ int operator<<(S, int);
200
+ int i, j;
201
+ int x = S(i=1) << (i=2);
202
+ int y = operator<<(S(j=1), j=2);
203
+ ```
204
+
205
+ After performing the initializations, the value of `i` is 2 (see 
206
+ [[expr.shift]]), but it is unspecified whether the value of `j` is 1 or
207
+ 2.
208
+
209
+ — *end example*]
210
+
211
+ The result of a function call is the result of the possibly-converted
212
+ operand of the `return` statement [[stmt.return]] that transferred
213
+ control out of the called function (if any), except in a virtual
214
+ function call if the return type of the final overrider is different
215
+ from the return type of the statically chosen function, the value
216
+ returned from the final overrider is converted to the return type of the
217
+ statically chosen function.
218
+
219
+ [*Note 9*: A function can change the values of its non-const
220
+ parameters, but these changes cannot affect the values of the arguments
221
+ except where a parameter is of a reference type [[dcl.ref]]; if the
222
+ reference is to a const-qualified type, `const_cast` is required to be
223
+ used to cast away the constness in order to modify the argument’s value.
224
+ Where a parameter is of `const` reference type a temporary object is
225
+ introduced if needed ([[dcl.type]], [[lex.literal]], [[lex.string]],
226
+ [[dcl.array]], [[class.temporary]]). In addition, it is possible to
227
+ modify the values of non-constant objects through pointer
228
+ parameters. — *end note*]
229
+
230
+ A function can be declared to accept fewer arguments (by declaring
231
+ default arguments [[dcl.fct.default]]) or more arguments (by using the
232
+ ellipsis, `...`, or a function parameter pack [[dcl.fct]]) than the
233
+ number of parameters in the function definition [[dcl.fct.def]].
234
+
235
+ [*Note 10*: This implies that, except where the ellipsis (`...`) or a
236
+ function parameter pack is used, a parameter is available for each
237
+ argument. — *end note*]
238
+
239
+ When there is no parameter for a given argument, the argument is passed
240
+ in such a way that the receiving function can obtain the value of the
241
+ argument by invoking `va_arg` [[support.runtime]].
242
+
243
+ [*Note 11*: This paragraph does not apply to arguments passed to a
244
+ function parameter pack. Function parameter packs are expanded during
245
+ template instantiation [[temp.variadic]], thus each such argument has a
246
+ corresponding parameter when a function template specialization is
247
+ actually called. — *end note*]
248
+
249
+ The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
250
+ function-to-pointer [[conv.func]] standard conversions are performed on
251
+ the argument expression. An argument that has type cv `std::nullptr_t`
252
+ is converted to type `void*` [[conv.ptr]]. After these conversions, if
253
+ the argument does not have arithmetic, enumeration, pointer,
254
+ pointer-to-member, or class type, the program is ill-formed. Passing a
255
+ potentially-evaluated argument of a scoped enumeration type or of a
256
+ class type [[class]] having an eligible non-trivial copy constructor, an
257
+ eligible non-trivial move constructor, or a non-trivial destructor
258
+ [[special]], with no corresponding parameter, is conditionally-supported
259
+ with *implementation-defined* semantics. If the argument has integral or
260
+ enumeration type that is subject to the integral promotions
261
+ [[conv.prom]], or a floating-point type that is subject to the
262
+ floating-point promotion [[conv.fpprom]], the value of the argument is
263
+ converted to the promoted type before the call. These promotions are
264
+ referred to as the *default argument promotions*.
265
+
266
+ Recursive calls are permitted, except to the `main` function
267
+ [[basic.start.main]].
268
+
269
+ A function call is an lvalue if the result type is an lvalue reference
270
+ type or an rvalue reference to function type, an xvalue if the result
271
+ type is an rvalue reference to object type, and a prvalue otherwise.
272
+
273
+ #### Explicit type conversion (functional notation) <a id="expr.type.conv">[[expr.type.conv]]</a>
274
+
275
+ A *simple-type-specifier* [[dcl.type.simple]] or *typename-specifier*
276
+ [[temp.res]] followed by a parenthesized optional *expression-list* or
277
+ by a *braced-init-list* (the initializer) constructs a value of the
278
+ specified type given the initializer. If the type is a placeholder for a
279
+ deduced class type, it is replaced by the return type of the function
280
+ selected by overload resolution for class template deduction
281
+ [[over.match.class.deduct]] for the remainder of this subclause.
282
+
283
+ If the initializer is a parenthesized single expression, the type
284
+ conversion expression is equivalent to the corresponding cast expression
285
+ [[expr.cast]]. Otherwise, if the type is cv `void` and the initializer
286
+ is `()` or `{}` (after pack expansion, if any), the expression is a
287
+ prvalue of the specified type that performs no initialization.
288
+ Otherwise, the expression is a prvalue of the specified type whose
289
+ result object is direct-initialized [[dcl.init]] with the initializer.
290
+ If the initializer is a parenthesized optional *expression-list*, the
291
+ specified type shall not be an array type.
292
+
293
+ #### Class member access <a id="expr.ref">[[expr.ref]]</a>
294
+
295
+ A postfix expression followed by a dot `.` or an arrow `->`, optionally
296
+ followed by the keyword `template` [[temp.names]], and then followed by
297
+ an *id-expression*, is a postfix expression. The postfix expression
298
+ before the dot or arrow is evaluated;[^12] the result of that
299
+ evaluation, together with the *id-expression*, determines the result of
300
+ the entire postfix expression.
301
+
302
+ For the first option (dot) the first expression shall be a glvalue. For
303
+ the second option (arrow) the first expression shall be a prvalue having
304
+ pointer type. The expression `E1->E2` is converted to the equivalent
305
+ form `(*(E1)).E2`; the remainder of [[expr.ref]] will address only the
306
+ first option (dot).[^13]
307
+
308
+ Abbreviating *postfix-expression*`.`*id-expression* as `E1.E2`, `E1` is
309
+ called the *object expression*. If the object expression is of scalar
310
+ type, `E2` shall name the pseudo-destructor of that same type (ignoring
311
+ cv-qualifications) and `E1.E2` is an lvalue of type “function of ()
312
+ returning `void`”.
313
+
314
+ [*Note 1*: This value can only be used for a notional function call
315
+ [[expr.prim.id.dtor]]. — *end note*]
316
+
317
+ Otherwise, the object expression shall be of class type. The class type
318
+ shall be complete unless the class member access appears in the
319
+ definition of that class.
320
+
321
+ [*Note 2*: If the class is incomplete, lookup in the complete class
322
+ type is required to refer to the same declaration
323
+ [[basic.scope.class]]. — *end note*]
324
+
325
+ The *id-expression* shall name a member of the class or of one of its
326
+ base classes.
327
+
328
+ [*Note 3*: Because the name of a class is inserted in its class scope
329
+ [[class]], the name of a class is also considered a nested member of
330
+ that class. — *end note*]
331
+
332
+ [*Note 4*: [[basic.lookup.classref]] describes how names are looked up
333
+ after the `.` and `->` operators. — *end note*]
334
+
335
+ If `E2` is a bit-field, `E1.E2` is a bit-field. The type and value
336
+ category of `E1.E2` are determined as follows. In the remainder of 
337
+ [[expr.ref]], *cq* represents either `const` or the absence of `const`
338
+ and *vq* represents either `volatile` or the absence of `volatile`. *cv*
339
+ represents an arbitrary set of cv-qualifiers, as defined in 
340
+ [[basic.type.qualifier]].
341
+
342
+ If `E2` is declared to have type “reference to `T`”, then `E1.E2` is an
343
+ lvalue; the type of `E1.E2` is `T`. Otherwise, one of the following
344
+ rules applies.
345
+
346
+ - If `E2` is a static data member and the type of `E2` is `T`, then
347
+ `E1.E2` is an lvalue; the expression designates the named member of
348
+ the class. The type of `E1.E2` is `T`.
349
+ - If `E2` is a non-static data member and the type of `E1` is “*cq1 vq1*
350
+ `X`”, and the type of `E2` is “*cq2 vq2* `T`”, the expression
351
+ designates the corresponding member subobject of the object designated
352
+ by the first expression. If `E1` is an lvalue, then `E1.E2` is an
353
+ lvalue; otherwise `E1.E2` is an xvalue. Let the notation *vq12* stand
354
+ for the “union” of *vq1* and *vq2*; that is, if *vq1* or *vq2* is
355
+ `volatile`, then *vq12* is `volatile`. Similarly, let the notation
356
+ *cq12* stand for the “union” of *cq1* and *cq2*; that is, if *cq1* or
357
+ *cq2* is `const`, then *cq12* is `const`. If `E2` is declared to be a
358
+ `mutable` member, then the type of `E1.E2` is “*vq12* `T`”. If `E2` is
359
+ not declared to be a `mutable` member, then the type of `E1.E2` is
360
+ “*cq12* *vq12* `T`”.
361
+ - If `E2` is a (possibly overloaded) member function, function overload
362
+ resolution [[over.match]] is used to select the function to which `E2`
363
+ refers. The type of `E1.E2` is the type of `E2` and `E1.E2` refers to
364
+ the function referred to by `E2`.
365
+ - If `E2` refers to a static member function, `E1.E2` is an lvalue.
366
+ - Otherwise (when `E2` refers to a non-static member function),
367
+ `E1.E2` is a prvalue. The expression can be used only as the
368
+ left-hand operand of a member function call [[class.mfct]].
369
+ \[*Note 5*: Any redundant set of parentheses surrounding the
370
+ expression is ignored [[expr.prim.paren]]. — *end note*]
371
+ - If `E2` is a nested type, the expression `E1.E2` is ill-formed.
372
+ - If `E2` is a member enumerator and the type of `E2` is `T`, the
373
+ expression `E1.E2` is a prvalue. The type of `E1.E2` is `T`.
374
+
375
+ If `E2` is a non-static data member or a non-static member function, the
376
+ program is ill-formed if the class of which `E2` is directly a member is
377
+ an ambiguous base [[class.member.lookup]] of the naming class
378
+ [[class.access.base]] of `E2`.
379
+
380
+ [*Note 6*: The program is also ill-formed if the naming class is an
381
+ ambiguous base of the class type of the object expression; see 
382
+ [[class.access.base]]. — *end note*]
383
+
384
+ #### Increment and decrement <a id="expr.post.incr">[[expr.post.incr]]</a>
385
+
386
+ The value of a postfix `++` expression is the value of its operand.
387
+
388
+ [*Note 1*: The value obtained is a copy of the original
389
+ value. — *end note*]
390
+
391
+ The operand shall be a modifiable lvalue. The type of the operand shall
392
+ be an arithmetic type other than cv `bool`, or a pointer to a complete
393
+ object type. An operand with volatile-qualified type is deprecated; see 
394
+ [[depr.volatile.type]]. The value of the operand object is modified
395
+ [[defns.access]] by adding `1` to it. The value computation of the `++`
396
+ expression is sequenced before the modification of the operand object.
397
+ With respect to an indeterminately-sequenced function call, the
398
+ operation of postfix `++` is a single evaluation.
399
+
400
+ [*Note 2*: Therefore, a function call cannot intervene between the
401
+ lvalue-to-rvalue conversion and the side effect associated with any
402
+ single postfix `++` operator. — *end note*]
403
+
404
+ The result is a prvalue. The type of the result is the cv-unqualified
405
+ version of the type of the operand. If the operand is a bit-field that
406
+ cannot represent the incremented value, the resulting value of the
407
+ bit-field is *implementation-defined*. See also  [[expr.add]] and 
408
+ [[expr.ass]].
409
+
410
+ The operand of postfix `\dcr` is decremented analogously to the postfix
411
+ `++` operator.
412
+
413
+ [*Note 3*: For prefix increment and decrement, see 
414
+ [[expr.pre.incr]]. — *end note*]
415
+
416
+ #### Dynamic cast <a id="expr.dynamic.cast">[[expr.dynamic.cast]]</a>
417
+
418
+ The result of the expression `dynamic_cast<T>(v)` is the result of
419
+ converting the expression `v` to type `T`. `T` shall be a pointer or
420
+ reference to a complete class type, or “pointer to cv `void`”. The
421
+ `dynamic_cast` operator shall not cast away constness
422
+ [[expr.const.cast]].
423
+
424
+ If `T` is a pointer type, `v` shall be a prvalue of a pointer to
425
+ complete class type, and the result is a prvalue of type `T`. If `T` is
426
+ an lvalue reference type, `v` shall be an lvalue of a complete class
427
+ type, and the result is an lvalue of the type referred to by `T`. If `T`
428
+ is an rvalue reference type, `v` shall be a glvalue having a complete
429
+ class type, and the result is an xvalue of the type referred to by `T`.
430
+
431
+ If the type of `v` is the same as `T` (ignoring cv-qualifications), the
432
+ result is `v` (converted if necessary).
433
+
434
+ If `T` is “pointer to *cv1* `B`” and `v` has type “pointer to *cv2* `D`”
435
+ such that `B` is a base class of `D`, the result is a pointer to the
436
+ unique `B` subobject of the `D` object pointed to by `v`, or a null
437
+ pointer value if `v` is a null pointer value. Similarly, if `T` is
438
+ “reference to *cv1* `B`” and `v` has type *cv2* `D` such that `B` is a
439
+ base class of `D`, the result is the unique `B` subobject of the `D`
440
+ object referred to by `v`.[^14] In both the pointer and reference cases,
441
+ the program is ill-formed if `B` is an inaccessible or ambiguous base
442
+ class of `D`.
443
+
444
+ [*Example 1*:
445
+
446
+ ``` cpp
447
+ struct B { };
448
+ struct D : B { };
449
+ void foo(D* dp) {
450
+ B* bp = dynamic_cast<B*>(dp); // equivalent to B* bp = dp;
451
+ }
452
+ ```
453
+
454
+ — *end example*]
455
+
456
+ Otherwise, `v` shall be a pointer to or a glvalue of a polymorphic type
457
+ [[class.virtual]].
458
+
459
+ If `v` is a null pointer value, the result is a null pointer value.
460
+
461
+ If `T` is “pointer to cv `void`”, then the result is a pointer to the
462
+ most derived object pointed to by `v`. Otherwise, a runtime check is
463
+ applied to see if the object pointed or referred to by `v` can be
464
+ converted to the type pointed or referred to by `T`.
465
+
466
+ If `C` is the class type to which `T` points or refers, the runtime
467
+ check logically executes as follows:
468
+
469
+ - If, in the most derived object pointed (referred) to by `v`, `v`
470
+ points (refers) to a public base class subobject of a `C` object, and
471
+ if only one object of type `C` is derived from the subobject pointed
472
+ (referred) to by `v` the result points (refers) to that `C` object.
473
+ - Otherwise, if `v` points (refers) to a public base class subobject of
474
+ the most derived object, and the type of the most derived object has a
475
+ base class, of type `C`, that is unambiguous and public, the result
476
+ points (refers) to the `C` subobject of the most derived object.
477
+ - Otherwise, the runtime check *fails*.
478
+
479
+ The value of a failed cast to pointer type is the null pointer value of
480
+ the required result type. A failed cast to reference type throws an
481
+ exception [[except.throw]] of a type that would match a handler
482
+ [[except.handle]] of type `std::bad_cast` [[bad.cast]].
483
+
484
+ [*Example 2*:
485
+
486
+ ``` cpp
487
+ class A { virtual void f(); };
488
+ class B { virtual void g(); };
489
+ class D : public virtual A, private B { };
490
+ void g() {
491
+ D d;
492
+ B* bp = (B*)&d; // cast needed to break protection
493
+ A* ap = &d; // public derivation, no cast needed
494
+ D& dr = dynamic_cast<D&>(*bp); // fails
495
+ ap = dynamic_cast<A*>(bp); // fails
496
+ bp = dynamic_cast<B*>(ap); // fails
497
+ ap = dynamic_cast<A*>(&d); // succeeds
498
+ bp = dynamic_cast<B*>(&d); // ill-formed (not a runtime check)
499
+ }
500
+
501
+ class E : public D, public B { };
502
+ class F : public E, public D { };
503
+ void h() {
504
+ F f;
505
+ A* ap = &f; // succeeds: finds unique A
506
+ D* dp = dynamic_cast<D*>(ap); // fails: yields null; f has two D subobjects
507
+ E* ep = (E*)ap; // error: cast from virtual base
508
+ E* ep1 = dynamic_cast<E*>(ap); // succeeds
509
+ }
510
+ ```
511
+
512
+ — *end example*]
513
+
514
+ [*Note 1*: Subclause [[class.cdtor]] describes the behavior of a
515
+ `dynamic_cast` applied to an object under construction or
516
+ destruction. — *end note*]
517
+
518
+ #### Type identification <a id="expr.typeid">[[expr.typeid]]</a>
519
+
520
+ The result of a `typeid` expression is an lvalue of static type `const`
521
+ `std::type_info` [[type.info]] and dynamic type `const` `std::type_info`
522
+ or `const` *name* where *name* is an *implementation-defined* class
523
+ publicly derived from `std::type_info` which preserves the behavior
524
+ described in  [[type.info]].[^15] The lifetime of the object referred to
525
+ by the lvalue extends to the end of the program. Whether or not the
526
+ destructor is called for the `std::type_info` object at the end of the
527
+ program is unspecified.
528
+
529
+ When `typeid` is applied to a glvalue whose type is a polymorphic class
530
+ type [[class.virtual]], the result refers to a `std::type_info` object
531
+ representing the type of the most derived object [[intro.object]] (that
532
+ is, the dynamic type) to which the glvalue refers. If the glvalue is
533
+ obtained by applying the unary `*` operator to a pointer[^16] and the
534
+ pointer is a null pointer value [[basic.compound]], the `typeid`
535
+ expression throws an exception [[except.throw]] of a type that would
536
+ match a handler of type `std::bad_typeid` exception [[bad.typeid]].
537
+
538
+ When `typeid` is applied to an expression other than a glvalue of a
539
+ polymorphic class type, the result refers to a `std::type_info` object
540
+ representing the static type of the expression. Lvalue-to-rvalue
541
+ [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
542
+ [[conv.func]] conversions are not applied to the expression. If the
543
+ expression is a prvalue, the temporary materialization conversion
544
+ [[conv.rval]] is applied. The expression is an unevaluated operand
545
+ [[expr.prop]].
546
+
547
+ When `typeid` is applied to a *type-id*, the result refers to a
548
+ `std::type_info` object representing the type of the *type-id*. If the
549
+ type of the *type-id* is a reference to a possibly cv-qualified type,
550
+ the result of the `typeid` expression refers to a `std::type_info`
551
+ object representing the cv-unqualified referenced type. If the type of
552
+ the *type-id* is a class type or a reference to a class type, the class
553
+ shall be completely-defined.
554
+
555
+ [*Note 1*: The *type-id* cannot denote a function type with a
556
+ *cv-qualifier-seq* or a *ref-qualifier* [[dcl.fct]]. — *end note*]
557
+
558
+ If the type of the expression or *type-id* is a cv-qualified type, the
559
+ result of the `typeid` expression refers to a `std::type_info` object
560
+ representing the cv-unqualified type.
561
+
562
+ [*Example 1*:
563
+
564
+ ``` cpp
565
+ class D { ... };
566
+ D d1;
567
+ const D d2;
568
+
569
+ typeid(d1) == typeid(d2); // yields true
570
+ typeid(D) == typeid(const D); // yields true
571
+ typeid(D) == typeid(d2); // yields true
572
+ typeid(D) == typeid(const D&); // yields true
573
+ ```
574
+
575
+ — *end example*]
576
+
577
+ If the header `<typeinfo>` is not imported or included prior to a use of
578
+ `typeid`, the program is ill-formed.
579
+
580
+ [*Note 2*: Subclause [[class.cdtor]] describes the behavior of `typeid`
581
+ applied to an object under construction or destruction. — *end note*]
582
+
583
+ #### Static cast <a id="expr.static.cast">[[expr.static.cast]]</a>
584
+
585
+ The result of the expression `static_cast<T>(v)` is the result of
586
+ converting the expression `v` to type `T`. If `T` is an lvalue reference
587
+ type or an rvalue reference to function type, the result is an lvalue;
588
+ if `T` is an rvalue reference to object type, the result is an xvalue;
589
+ otherwise, the result is a prvalue. The `static_cast` operator shall not
590
+ cast away constness [[expr.const.cast]].
591
+
592
+ An lvalue of type “*cv1* `B`”, where `B` is a class type, can be cast to
593
+ type “reference to *cv2* `D`”, where `D` is a class derived
594
+ [[class.derived]] from `B`, if *cv2* is the same cv-qualification as, or
595
+ greater cv-qualification than, *cv1*. If `B` is a virtual base class of
596
+ `D` or a base class of a virtual base class of `D`, or if no valid
597
+ standard conversion from “pointer to `D`” to “pointer to `B`” exists
598
+ [[conv.ptr]], the program is ill-formed. An xvalue of type “*cv1* `B`”
599
+ can be cast to type “rvalue reference to *cv2* `D`” with the same
600
+ constraints as for an lvalue of type “*cv1* `B`”. If the object of type
601
+ “*cv1* `B`” is actually a base class subobject of an object of type `D`,
602
+ the result refers to the enclosing object of type `D`. Otherwise, the
603
+ behavior is undefined.
604
+
605
+ [*Example 1*:
606
+
607
+ ``` cpp
608
+ struct B { };
609
+ struct D : public B { };
610
+ D d;
611
+ B &br = d;
612
+
613
+ static_cast<D&>(br); // produces lvalue denoting the original d object
614
+ ```
615
+
616
+ — *end example*]
617
+
618
+ An lvalue of type “*cv1* `T1`” can be cast to type “rvalue reference to
619
+ *cv2* `T2`” if “*cv2* `T2`” is reference-compatible with “*cv1* `T1`”
620
+ [[dcl.init.ref]]. If the value is not a bit-field, the result refers to
621
+ the object or the specified base class subobject thereof; otherwise, the
622
+ lvalue-to-rvalue conversion [[conv.lval]] is applied to the bit-field
623
+ and the resulting prvalue is used as the *expression* of the
624
+ `static_cast` for the remainder of this subclause. If `T2` is an
625
+ inaccessible [[class.access]] or ambiguous [[class.member.lookup]] base
626
+ class of `T1`, a program that necessitates such a cast is ill-formed.
627
+
628
+ An expression E can be explicitly converted to a type `T` if there is an
629
+ implicit conversion sequence [[over.best.ics]] from E to `T`, if
630
+ overload resolution for a direct-initialization [[dcl.init]] of an
631
+ object or reference of type `T` from E would find at least one viable
632
+ function [[over.match.viable]], or if `T` is an aggregate type
633
+ [[dcl.init.aggr]] having a first element `x` and there is an implicit
634
+ conversion sequence from E to the type of `x`. If `T` is a reference
635
+ type, the effect is the same as performing the declaration and
636
+ initialization
637
+
638
+ ``` cpp
639
+ T t(E);
640
+ ```
641
+
642
+ for some invented temporary variable `t` [[dcl.init]] and then using the
643
+ temporary variable as the result of the conversion. Otherwise, the
644
+ result object is direct-initialized from E.
645
+
646
+ [*Note 1*: The conversion is ill-formed when attempting to convert an
647
+ expression of class type to an inaccessible or ambiguous base
648
+ class. — *end note*]
649
+
650
+ [*Note 2*: If `T` is “array of unknown bound of `U`”, this
651
+ direct-initialization defines the type of the expression as
652
+ `U[1]`. — *end note*]
653
+
654
+ Otherwise, the `static_cast` shall perform one of the conversions listed
655
+ below. No other conversion shall be performed explicitly using a
656
+ `static_cast`.
657
+
658
+ Any expression can be explicitly converted to type cv `void`, in which
659
+ case it becomes a discarded-value expression [[expr.prop]].
660
+
661
+ [*Note 3*: However, if the value is in a temporary object
662
+ [[class.temporary]], the destructor for that object is not executed
663
+ until the usual time, and the value of the object is preserved for the
664
+ purpose of executing the destructor. — *end note*]
665
+
666
+ The inverse of any standard conversion sequence [[conv]] not containing
667
+ an lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]],
668
+ function-to-pointer [[conv.func]], null pointer [[conv.ptr]], null
669
+ member pointer [[conv.mem]], boolean [[conv.bool]], or function pointer
670
+ [[conv.fctptr]] conversion, can be performed explicitly using
671
+ `static_cast`. A program is ill-formed if it uses `static_cast` to
672
+ perform the inverse of an ill-formed standard conversion sequence.
673
+
674
+ [*Example 2*:
675
+
676
+ ``` cpp
677
+ struct B { };
678
+ struct D : private B { };
679
+ void f() {
680
+ static_cast<D*>((B*)0); // error: B is a private base of D
681
+ static_cast<int B::*>((int D::*)0); // error: B is a private base of D
682
+ }
683
+ ```
684
+
685
+ — *end example*]
686
+
687
+ The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
688
+ function-to-pointer [[conv.func]] conversions are applied to the
689
+ operand. Such a `static_cast` is subject to the restriction that the
690
+ explicit conversion does not cast away constness [[expr.const.cast]],
691
+ and the following additional rules for specific cases:
692
+
693
+ A value of a scoped enumeration type [[dcl.enum]] can be explicitly
694
+ converted to an integral type; the result is the same as that of
695
+ converting to the enumeration’s underlying type and then to the
696
+ destination type. A value of a scoped enumeration type can also be
697
+ explicitly converted to a floating-point type; the result is the same as
698
+ that of converting from the original value to the floating-point type.
699
+
700
+ A value of integral or enumeration type can be explicitly converted to a
701
+ complete enumeration type. If the enumeration type has a fixed
702
+ underlying type, the value is first converted to that type by integral
703
+ conversion, if necessary, and then to the enumeration type. If the
704
+ enumeration type does not have a fixed underlying type, the value is
705
+ unchanged if the original value is within the range of the enumeration
706
+ values [[dcl.enum]], and otherwise, the behavior is undefined. A value
707
+ of floating-point type can also be explicitly converted to an
708
+ enumeration type. The resulting value is the same as converting the
709
+ original value to the underlying type of the enumeration [[conv.fpint]],
710
+ and subsequently to the enumeration type.
711
+
712
+ A prvalue of type “pointer to *cv1* `B`”, where `B` is a class type, can
713
+ be converted to a prvalue of type “pointer to *cv2* `D`”, where `D` is a
714
+ complete class derived [[class.derived]] from `B`, if *cv2* is the same
715
+ cv-qualification as, or greater cv-qualification than, *cv1*. If `B` is
716
+ a virtual base class of `D` or a base class of a virtual base class of
717
+ `D`, or if no valid standard conversion from “pointer to `D`” to
718
+ “pointer to `B`” exists [[conv.ptr]], the program is ill-formed. The
719
+ null pointer value [[basic.compound]] is converted to the null pointer
720
+ value of the destination type. If the prvalue of type “pointer to *cv1*
721
+ `B`” points to a `B` that is actually a subobject of an object of type
722
+ `D`, the resulting pointer points to the enclosing object of type `D`.
723
+ Otherwise, the behavior is undefined.
724
+
725
+ A prvalue of type “pointer to member of `D` of type *cv1* `T`” can be
726
+ converted to a prvalue of type “pointer to member of `B` of type *cv2*
727
+ `T`”, where `D` is a complete class type and `B` is a base class
728
+ [[class.derived]] of `D`, if *cv2* is the same cv-qualification as, or
729
+ greater cv-qualification than, *cv1*.
730
+
731
+ [*Note 4*: Function types (including those used in
732
+ pointer-to-member-function types) are never cv-qualified
733
+ [[dcl.fct]]. — *end note*]
734
+
735
+ If no valid standard conversion from “pointer to member of `B` of type
736
+ `T`” to “pointer to member of `D` of type `T`” exists [[conv.mem]], the
737
+ program is ill-formed. The null member pointer value [[conv.mem]] is
738
+ converted to the null member pointer value of the destination type. If
739
+ class `B` contains the original member, or is a base or derived class of
740
+ the class containing the original member, the resulting pointer to
741
+ member points to the original member. Otherwise, the behavior is
742
+ undefined.
743
+
744
+ [*Note 5*: Although class `B` need not contain the original member, the
745
+ dynamic type of the object with which indirection through the pointer to
746
+ member is performed must contain the original member; see 
747
+ [[expr.mptr.oper]]. — *end note*]
748
+
749
+ A prvalue of type “pointer to *cv1* `void`” can be converted to a
750
+ prvalue of type “pointer to *cv2* `T`”, where `T` is an object type and
751
+ *cv2* is the same cv-qualification as, or greater cv-qualification than,
752
+ *cv1*. If the original pointer value represents the address `A` of a
753
+ byte in memory and `A` does not satisfy the alignment requirement of
754
+ `T`, then the resulting pointer value is unspecified. Otherwise, if the
755
+ original pointer value points to an object *a*, and there is an object
756
+ *b* of type `T` (ignoring cv-qualification) that is
757
+ pointer-interconvertible [[basic.compound]] with *a*, the result is a
758
+ pointer to *b*. Otherwise, the pointer value is unchanged by the
759
+ conversion.
760
+
761
+ [*Example 3*:
762
+
763
+ ``` cpp
764
+ T* p1 = new T;
765
+ const T* p2 = static_cast<const T*>(static_cast<void*>(p1));
766
+ bool b = p1 == p2; // b will have the value true.
767
+ ```
768
+
769
+ — *end example*]
770
+
771
+ #### Reinterpret cast <a id="expr.reinterpret.cast">[[expr.reinterpret.cast]]</a>
772
+
773
+ The result of the expression `reinterpret_cast<T>(v)` is the result of
774
+ converting the expression `v` to type `T`. If `T` is an lvalue reference
775
+ type or an rvalue reference to function type, the result is an lvalue;
776
+ if `T` is an rvalue reference to object type, the result is an xvalue;
777
+ otherwise, the result is a prvalue and the lvalue-to-rvalue
778
+ [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
779
+ [[conv.func]] standard conversions are performed on the expression `v`.
780
+ Conversions that can be performed explicitly using `reinterpret_cast`
781
+ are listed below. No other conversion can be performed explicitly using
782
+ `reinterpret_cast`.
783
+
784
+ The `reinterpret_cast` operator shall not cast away constness
785
+ [[expr.const.cast]]. An expression of integral, enumeration, pointer, or
786
+ pointer-to-member type can be explicitly converted to its own type; such
787
+ a cast yields the value of its operand.
788
+
789
+ [*Note 1*: The mapping performed by `reinterpret_cast` might, or might
790
+ not, produce a representation different from the original
791
+ value. — *end note*]
792
+
793
+ A pointer can be explicitly converted to any integral type large enough
794
+ to hold all values of its type. The mapping function is
795
+ *implementation-defined*.
796
+
797
+ [*Note 2*: It is intended to be unsurprising to those who know the
798
+ addressing structure of the underlying machine. — *end note*]
799
+
800
+ A value of type `std::nullptr_t` can be converted to an integral type;
801
+ the conversion has the same meaning and validity as a conversion of
802
+ `(void*)0` to the integral type.
803
+
804
+ [*Note 3*: A `reinterpret_cast` cannot be used to convert a value of
805
+ any type to the type `std::nullptr_t`. — *end note*]
806
+
807
+ A value of integral type or enumeration type can be explicitly converted
808
+ to a pointer. A pointer converted to an integer of sufficient size (if
809
+ any such exists on the implementation) and back to the same pointer type
810
+ will have its original value; mappings between pointers and integers are
811
+ otherwise *implementation-defined*.
812
+
813
+ [*Note 4*: Except as described in [[basic.stc.dynamic.safety]], the
814
+ result of such a conversion will not be a safely-derived pointer
815
+ value. — *end note*]
816
+
817
+ A function pointer can be explicitly converted to a function pointer of
818
+ a different type.
819
+
820
+ [*Note 5*: The effect of calling a function through a pointer to a
821
+ function type [[dcl.fct]] that is not the same as the type used in the
822
+ definition of the function is undefined [[expr.call]]. — *end note*]
823
+
824
+ Except that converting a prvalue of type “pointer to `T1`” to the type
825
+ “pointer to `T2`” (where `T1` and `T2` are function types) and back to
826
+ its original type yields the original pointer value, the result of such
827
+ a pointer conversion is unspecified.
828
+
829
+ [*Note 6*: See also  [[conv.ptr]] for more details of pointer
830
+ conversions. — *end note*]
831
+
832
+ An object pointer can be explicitly converted to an object pointer of a
833
+ different type.[^17] When a prvalue `v` of object pointer type is
834
+ converted to the object pointer type “pointer to cv `T`”, the result is
835
+ `static_cast<cv T*>(static_cast<cv~void*>(v))`.
836
+
837
+ [*Note 7*: Converting a prvalue of type “pointer to `T1`” to the type
838
+ “pointer to `T2`” (where `T1` and `T2` are object types and where the
839
+ alignment requirements of `T2` are no stricter than those of `T1`) and
840
+ back to its original type yields the original pointer
841
+ value. — *end note*]
842
+
843
+ Converting a function pointer to an object pointer type or vice versa is
844
+ conditionally-supported. The meaning of such a conversion is
845
+ *implementation-defined*, except that if an implementation supports
846
+ conversions in both directions, converting a prvalue of one type to the
847
+ other type and back, possibly with different cv-qualification, shall
848
+ yield the original pointer value.
849
+
850
+ The null pointer value [[basic.compound]] is converted to the null
851
+ pointer value of the destination type.
852
+
853
+ [*Note 8*: A null pointer constant of type `std::nullptr_t` cannot be
854
+ converted to a pointer type, and a null pointer constant of integral
855
+ type is not necessarily converted to a null pointer
856
+ value. — *end note*]
857
+
858
+ A prvalue of type “pointer to member of `X` of type `T1`” can be
859
+ explicitly converted to a prvalue of a different type “pointer to member
860
+ of `Y` of type `T2`” if `T1` and `T2` are both function types or both
861
+ object types.[^18] The null member pointer value [[conv.mem]] is
862
+ converted to the null member pointer value of the destination type. The
863
+ result of this conversion is unspecified, except in the following cases:
864
+
865
+ - Converting a prvalue of type “pointer to member function” to a
866
+ different pointer-to-member-function type and back to its original
867
+ type yields the original pointer-to-member value.
868
+ - Converting a prvalue of type “pointer to data member of `X` of type
869
+ `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
870
+ the alignment requirements of `T2` are no stricter than those of `T1`)
871
+ and back to its original type yields the original pointer-to-member
872
+ value.
873
+
874
+ A glvalue of type `T1`, designating an object *x*, can be cast to the
875
+ type “reference to `T2`” if an expression of type “pointer to `T1`” can
876
+ be explicitly converted to the type “pointer to `T2`” using a
877
+ `reinterpret_cast`. The result is that of `*reinterpret_cast<T2 *>(p)`
878
+ where `p` is a pointer to *x* of type “pointer to `T1`”. No temporary is
879
+ created, no copy is made, and no constructors [[class.ctor]] or
880
+ conversion functions [[class.conv]] are called. [^19]
881
+
882
+ #### Const cast <a id="expr.const.cast">[[expr.const.cast]]</a>
883
+
884
+ The result of the expression `const_cast<T>(v)` is of type `T`. If `T`
885
+ is an lvalue reference to object type, the result is an lvalue; if `T`
886
+ is an rvalue reference to object type, the result is an xvalue;
887
+ otherwise, the result is a prvalue and the lvalue-to-rvalue
888
+ [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
889
+ [[conv.func]] standard conversions are performed on the expression `v`.
890
+ Conversions that can be performed explicitly using `const_cast` are
891
+ listed below. No other conversion shall be performed explicitly using
892
+ `const_cast`.
893
+
894
+ [*Note 1*: Subject to the restrictions in this subclause, an expression
895
+ may be cast to its own type using a `const_cast`
896
+ operator. — *end note*]
897
+
898
+ For two similar types `T1` and `T2` [[conv.qual]], a prvalue of type
899
+ `T1` may be explicitly converted to the type `T2` using a `const_cast`
900
+ if, considering the cv-decompositions of both types, each P¹ᵢ is the
901
+ same as P²ᵢ for all i. The result of a `const_cast` refers to the
902
+ original entity.
903
+
904
+ [*Example 1*:
905
+
906
+ ``` cpp
907
+ typedef int *A[3]; // array of 3 pointer to int
908
+ typedef const int *const CA[3]; // array of 3 const pointer to const int
909
+
910
+ CA &&r = A{}; // OK, reference binds to temporary array object
911
+ // after qualification conversion to type CA
912
+ A &&r1 = const_cast<A>(CA{}); // error: temporary array decayed to pointer
913
+ A &&r2 = const_cast<A&&>(CA{}); // OK
914
+ ```
915
+
916
+ — *end example*]
917
+
918
+ For two object types `T1` and `T2`, if a pointer to `T1` can be
919
+ explicitly converted to the type “pointer to `T2`” using a `const_cast`,
920
+ then the following conversions can also be made:
921
+
922
+ - an lvalue of type `T1` can be explicitly converted to an lvalue of
923
+ type `T2` using the cast `const_cast<T2&>`;
924
+ - a glvalue of type `T1` can be explicitly converted to an xvalue of
925
+ type `T2` using the cast `const_cast<T2&&>`; and
926
+ - if `T1` is a class type, a prvalue of type `T1` can be explicitly
927
+ converted to an xvalue of type `T2` using the cast `const_cast<T2&&>`.
928
+
929
+ The result of a reference `const_cast` refers to the original object if
930
+ the operand is a glvalue and to the result of applying the temporary
931
+ materialization conversion [[conv.rval]] otherwise.
932
+
933
+ A null pointer value [[basic.compound]] is converted to the null pointer
934
+ value of the destination type. The null member pointer value
935
+ [[conv.mem]] is converted to the null member pointer value of the
936
+ destination type.
937
+
938
+ [*Note 2*: Depending on the type of the object, a write operation
939
+ through the pointer, lvalue or pointer to data member resulting from a
940
+ `const_cast` that casts away a const-qualifier[^20] may produce
941
+ undefined behavior [[dcl.type.cv]]. — *end note*]
942
+
943
+ A conversion from a type `T1` to a type `T2` *casts away constness* if
944
+ `T1` and `T2` are different, there is a cv-decomposition [[conv.qual]]
945
+ of `T1` yielding *n* such that `T2` has a cv-decomposition of the form
946
+
947
+ and there is no qualification conversion that converts `T1` to
948
+
949
+ Casting from an lvalue of type `T1` to an lvalue of type `T2` using an
950
+ lvalue reference cast or casting from an expression of type `T1` to an
951
+ xvalue of type `T2` using an rvalue reference cast casts away constness
952
+ if a cast from a prvalue of type “pointer to `T1`” to the type “pointer
953
+ to `T2`” casts away constness.
954
+
955
+ [*Note 3*: Some conversions which involve only changes in
956
+ cv-qualification cannot be done using `const_cast.` For instance,
957
+ conversions between pointers to functions are not covered because such
958
+ conversions lead to values whose use causes undefined behavior. For the
959
+ same reasons, conversions between pointers to member functions, and in
960
+ particular, the conversion from a pointer to a const member function to
961
+ a pointer to a non-const member function, are not
962
+ covered. — *end note*]
963
+
964
+ ### Unary expressions <a id="expr.unary">[[expr.unary]]</a>
965
+
966
+ Expressions with unary operators group right-to-left.
967
+
968
+ ``` bnf
969
+ unary-expression:
970
+ postfix-expression
971
+ unary-operator cast-expression
972
+ '++' cast-expression
973
+ '-{-}' cast-expression
974
+ await-expression
975
+ sizeof unary-expression
976
+ sizeof '(' type-id ')'
977
+ sizeof '...' '(' identifier ')'
978
+ alignof '(' type-id ')'
979
+ noexcept-expression
980
+ new-expression
981
+ delete-expression
982
+ ```
983
+
984
+ ``` bnf
985
+ unary-operator: one of
986
+ '* & + - ! ~'
987
+ ```
988
+
989
+ #### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
990
+
991
+ The unary `*` operator performs *indirection*: the expression to which
992
+ it is applied shall be a pointer to an object type, or a pointer to a
993
+ function type and the result is an lvalue referring to the object or
994
+ function to which the expression points. If the type of the expression
995
+ is “pointer to `T`”, the type of the result is “`T`”.
996
+
997
+ [*Note 1*: Indirection through a pointer to an incomplete type (other
998
+ than cv `void`) is valid. The lvalue thus obtained can be used in
999
+ limited ways (to initialize a reference, for example); this lvalue must
1000
+ not be converted to a prvalue, see  [[conv.lval]]. — *end note*]
1001
+
1002
+ The result of each of the following unary operators is a prvalue.
1003
+
1004
+ The result of the unary `&` operator is a pointer to its operand.
1005
+
1006
+ - If the operand is a *qualified-id* naming a non-static or variant
1007
+ member `m` of some class `C` with type `T`, the result has type
1008
+ “pointer to member of class `C` of type `T`” and is a prvalue
1009
+ designating `C::m`.
1010
+ - Otherwise, if the operand is an lvalue of type `T`, the resulting
1011
+ expression is a prvalue of type “pointer to `T`” whose result is a
1012
+ pointer to the designated object [[intro.memory]] or function.
1013
+ \[*Note 2*: In particular, taking the address of a variable of type
1014
+ “cv `T`” yields a pointer of type “pointer to cv `T`”. — *end note*]
1015
+ - Otherwise, the program is ill-formed.
1016
+
1017
+ [*Example 1*:
1018
+
1019
+ ``` cpp
1020
+ struct A { int i; };
1021
+ struct B : A { };
1022
+ ... &B::i ... // has type int A::*
1023
+ int a;
1024
+ int* p1 = &a;
1025
+ int* p2 = p1 + 1; // defined behavior
1026
+ bool b = p2 > p1; // defined behavior, with value true
1027
+ ```
1028
+
1029
+ — *end example*]
1030
+
1031
+ [*Note 3*: A pointer to member formed from a `mutable` non-static data
1032
+ member [[dcl.stc]] does not reflect the `mutable` specifier associated
1033
+ with the non-static data member. — *end note*]
1034
+
1035
+ A pointer to member is only formed when an explicit `&` is used and its
1036
+ operand is a *qualified-id* not enclosed in parentheses.
1037
+
1038
+ [*Note 4*: That is, the expression `&(qualified-id)`, where the
1039
+ *qualified-id* is enclosed in parentheses, does not form an expression
1040
+ of type “pointer to member”. Neither does `qualified-id`, because there
1041
+ is no implicit conversion from a *qualified-id* for a non-static member
1042
+ function to the type “pointer to member function” as there is from an
1043
+ lvalue of function type to the type “pointer to function” [[conv.func]].
1044
+ Nor is `&unqualified-id` a pointer to member, even within the scope of
1045
+ the *unqualified-id*’s class. — *end note*]
1046
+
1047
+ If `&` is applied to an lvalue of incomplete class type and the complete
1048
+ type declares `operator&()`, it is unspecified whether the operator has
1049
+ the built-in meaning or the operator function is called. The operand of
1050
+ `&` shall not be a bit-field.
1051
+
1052
+ [*Note 5*: The address of an overloaded function [[over]] can be taken
1053
+ only in a context that uniquely determines which version of the
1054
+ overloaded function is referred to (see  [[over.over]]). Since the
1055
+ context might determine whether the operand is a static or non-static
1056
+ member function, the context can also affect whether the expression has
1057
+ type “pointer to function” or “pointer to member
1058
+ function”. — *end note*]
1059
+
1060
+ The operand of the unary `+` operator shall have arithmetic, unscoped
1061
+ enumeration, or pointer type and the result is the value of the
1062
+ argument. Integral promotion is performed on integral or enumeration
1063
+ operands. The type of the result is the type of the promoted operand.
1064
+
1065
+ The operand of the unary `-` operator shall have arithmetic or unscoped
1066
+ enumeration type and the result is the negation of its operand. Integral
1067
+ promotion is performed on integral or enumeration operands. The negative
1068
+ of an unsigned quantity is computed by subtracting its value from 2ⁿ,
1069
+ where n is the number of bits in the promoted operand. The type of the
1070
+ result is the type of the promoted operand.
1071
+
1072
+ The operand of the logical negation operator `!` is contextually
1073
+ converted to `bool` [[conv]]; its value is `true` if the converted
1074
+ operand is `false` and `false` otherwise. The type of the result is
1075
+ `bool`.
1076
+
1077
+ The operand of `~` shall have integral or unscoped enumeration type; the
1078
+ result is the ones’ complement of its operand. Integral promotions are
1079
+ performed. The type of the result is the type of the promoted operand.
1080
+ There is an ambiguity in the grammar when `~` is followed by a
1081
+ *type-name* or *decltype-specifier*. The ambiguity is resolved by
1082
+ treating `~` as the unary complement operator rather than as the start
1083
+ of an *unqualified-id* naming a destructor.
1084
+
1085
+ [*Note 6*: Because the grammar does not permit an operator to follow
1086
+ the `.`, `->`, or `::` tokens, a `~` followed by a *type-name* or
1087
+ *decltype-specifier* in a member access expression or *qualified-id* is
1088
+ unambiguously parsed as a destructor name. — *end note*]
1089
+
1090
+ #### Increment and decrement <a id="expr.pre.incr">[[expr.pre.incr]]</a>
1091
+
1092
+ The operand of prefix `++` is modified [[defns.access]] by adding `1`.
1093
+ The operand shall be a modifiable lvalue. The type of the operand shall
1094
+ be an arithmetic type other than cv `bool`, or a pointer to a
1095
+ completely-defined object type. An operand with volatile-qualified type
1096
+ is deprecated; see  [[depr.volatile.type]]. The result is the updated
1097
+ operand; it is an lvalue, and it is a bit-field if the operand is a
1098
+ bit-field. The expression `++x` is equivalent to `x+=1`.
1099
+
1100
+ [*Note 1*: See the discussions of addition [[expr.add]] and assignment
1101
+ operators [[expr.ass]] for information on conversions. — *end note*]
1102
+
1103
+ The operand of prefix `\dcr` is modified [[defns.access]] by subtracting
1104
+ `1`. The requirements on the operand of prefix `\dcr` and the properties
1105
+ of its result are otherwise the same as those of prefix `++`.
1106
+
1107
+ [*Note 2*: For postfix increment and decrement, see 
1108
+ [[expr.post.incr]]. — *end note*]
1109
+
1110
+ #### Await <a id="expr.await">[[expr.await]]</a>
1111
+
1112
+ The `co_await` expression is used to suspend evaluation of a coroutine
1113
+ [[dcl.fct.def.coroutine]] while awaiting completion of the computation
1114
+ represented by the operand expression.
1115
+
1116
+ ``` bnf
1117
+ await-expression:
1118
+ 'co_await' cast-expression
1119
+ ```
1120
+
1121
+ An *await-expression* shall appear only in a potentially-evaluated
1122
+ expression within the *compound-statement* of a *function-body* outside
1123
+ of a *handler* [[except.pre]]. In a *declaration-statement* or in the
1124
+ *simple-declaration* (if any) of a *for-init-statement*, an
1125
+ *await-expression* shall appear only in an *initializer* of that
1126
+ *declaration-statement* or *simple-declaration*. An *await-expression*
1127
+ shall not appear in a default argument [[dcl.fct.default]]. An
1128
+ *await-expression* shall not appear in the initializer of a block-scope
1129
+ variable with static or thread storage duration. A context within a
1130
+ function where an *await-expression* can appear is called a *suspension
1131
+ context* of the function.
1132
+
1133
+ Evaluation of an *await-expression* involves the following auxiliary
1134
+ types, expressions, and objects:
1135
+
1136
+ - *p* is an lvalue naming the promise object [[dcl.fct.def.coroutine]]
1137
+ of the enclosing coroutine and `P` is the type of that object.
1138
+ - *a* is the *cast-expression* if the *await-expression* was implicitly
1139
+ produced by a *yield-expression* [[expr.yield]], an initial suspend
1140
+ point, or a final suspend point [[dcl.fct.def.coroutine]]. Otherwise,
1141
+ the *unqualified-id* `await_transform` is looked up within the scope
1142
+ of `P` by class member access lookup [[basic.lookup.classref]], and if
1143
+ this lookup finds at least one declaration, then *a* is
1144
+ *p*`.await_transform(`*cast-expression*`)`; otherwise, *a* is the
1145
+ *cast-expression*.
1146
+ - *o* is determined by enumerating the applicable `operator co_await`
1147
+ functions for an argument *a* [[over.match.oper]], and choosing the
1148
+ best one through overload resolution [[over.match]]. If overload
1149
+ resolution is ambiguous, the program is ill-formed. If no viable
1150
+ functions are found, *o* is *a*. Otherwise, *o* is a call to the
1151
+ selected function with the argument *a*. If *o* would be a prvalue,
1152
+ the temporary materialization conversion [[conv.rval]] is applied.
1153
+ - *e* is an lvalue referring to the result of evaluating the
1154
+ (possibly-converted) *o*.
1155
+ - *h* is an object of type `std::coroutine_handle<P>` referring to the
1156
+ enclosing coroutine.
1157
+ - *await-ready* is the expression *e*`.await_ready()`, contextually
1158
+ converted to `bool`.
1159
+ - *await-suspend* is the expression *e*`.await_suspend(`*h*`)`, which
1160
+ shall be a prvalue of type `void`, `bool`, or
1161
+ `std::coroutine_handle<Z>` for some type `Z`.
1162
+ - *await-resume* is the expression *e*`.await_resume()`.
1163
+
1164
+ The *await-expression* has the same type and value category as the
1165
+ *await-resume* expression.
1166
+
1167
+ The *await-expression* evaluates the (possibly-converted) *o* expression
1168
+ and the *await-ready* expression, then:
1169
+
1170
+ - If the result of *await-ready* is `false`, the coroutine is considered
1171
+ suspended. Then:
1172
+ - If the type of *await-suspend* is `std::coroutine_handle<Z>`,
1173
+ *await-suspend*`.resume()` is evaluated. \[*Note 1*: This resumes
1174
+ the coroutine referred to by the result of *await-suspend*. Any
1175
+ number of coroutines may be successively resumed in this fashion,
1176
+ eventually returning control flow to the current coroutine caller or
1177
+ resumer [[dcl.fct.def.coroutine]]. — *end note*]
1178
+ - Otherwise, if the type of *await-suspend* is `bool`, *await-suspend*
1179
+ is evaluated, and the coroutine is resumed if the result is `false`.
1180
+ - Otherwise, *await-suspend* is evaluated.
1181
+
1182
+ If the evaluation of *await-suspend* exits via an exception, the
1183
+ exception is caught, the coroutine is resumed, and the exception is
1184
+ immediately re-thrown [[except.throw]]. Otherwise, control flow
1185
+ returns to the current coroutine caller or resumer
1186
+ [[dcl.fct.def.coroutine]] without exiting any scopes [[stmt.jump]].
1187
+ - If the result of *await-ready* is `true`, or when the coroutine is
1188
+ resumed, the *await-resume* expression is evaluated, and its result is
1189
+ the result of the *await-expression*.
1190
+
1191
+ [*Example 1*:
1192
+
1193
+ ``` cpp
1194
+ template <typename T>
1195
+ struct my_future {
1196
+ ...
1197
+ bool await_ready();
1198
+ void await_suspend(std::coroutine_handle<>);
1199
+ T await_resume();
1200
+ };
1201
+
1202
+ template <class Rep, class Period>
1203
+ auto operator co_await(std::chrono::duration<Rep, Period> d) {
1204
+ struct awaiter {
1205
+ std::chrono::system_clock::duration duration;
1206
+ ...
1207
+ awaiter(std::chrono::system_clock::duration d) : duration(d) {}
1208
+ bool await_ready() const { return duration.count() <= 0; }
1209
+ void await_resume() {}
1210
+ void await_suspend(std::coroutine_handle<> h) { ... }
1211
+ };
1212
+ return awaiter{d};
1213
+ }
1214
+
1215
+ using namespace std::chrono;
1216
+
1217
+ my_future<int> h();
1218
+
1219
+ my_future<void> g() {
1220
+ std::cout << "just about go to sleep...\n";
1221
+ co_await 10ms;
1222
+ std::cout << "resumed\n";
1223
+ co_await h();
1224
+ }
1225
+
1226
+ auto f(int x = co_await h()); // error: await-expression outside of function suspension context
1227
+ int a[] = { co_await h() }; // error: await-expression outside of function suspension context
1228
+ ```
1229
+
1230
+ — *end example*]
1231
+
1232
+ #### Sizeof <a id="expr.sizeof">[[expr.sizeof]]</a>
1233
+
1234
+ The `sizeof` operator yields the number of bytes occupied by a
1235
+ non-potentially-overlapping object of the type of its operand. The
1236
+ operand is either an expression, which is an unevaluated operand
1237
+ [[expr.prop]], or a parenthesized *type-id*. The `sizeof` operator shall
1238
+ not be applied to an expression that has function or incomplete type, to
1239
+ the parenthesized name of such types, or to a glvalue that designates a
1240
+ bit-field. The result of `sizeof` applied to any of the narrow character
1241
+ types is `1`. The result of `sizeof` applied to any other fundamental
1242
+ type [[basic.fundamental]] is *implementation-defined*.
1243
+
1244
+ [*Note 1*: In particular, `sizeof(bool)`, `sizeof(char16_t)`,
1245
+ `sizeof(char32_t)`, and `sizeof(wchar_t)` are
1246
+ implementation-defined.[^21] — *end note*]
1247
+
1248
+ [*Note 2*: See  [[intro.memory]] for the definition of byte and 
1249
+ [[basic.types]] for the definition of object
1250
+ representation. — *end note*]
1251
+
1252
+ When applied to a reference type, the result is the size of the
1253
+ referenced type. When applied to a class, the result is the number of
1254
+ bytes in an object of that class including any padding required for
1255
+ placing objects of that type in an array. The result of applying
1256
+ `sizeof` to a potentially-overlapping subobject is the size of the type,
1257
+ not the size of the subobject. [^22] When applied to an array, the
1258
+ result is the total number of bytes in the array. This implies that the
1259
+ size of an array of n elements is n times the size of an element.
1260
+
1261
+ The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
1262
+ function-to-pointer [[conv.func]] standard conversions are not applied
1263
+ to the operand of `sizeof`. If the operand is a prvalue, the temporary
1264
+ materialization conversion [[conv.rval]] is applied.
1265
+
1266
+ The identifier in a `sizeof...` expression shall name a pack. The
1267
+ `sizeof...` operator yields the number of elements in the pack
1268
+ [[temp.variadic]]. A `sizeof...` expression is a pack expansion
1269
+ [[temp.variadic]].
1270
+
1271
+ [*Example 1*:
1272
+
1273
+ ``` cpp
1274
+ template<class... Types>
1275
+ struct count {
1276
+ static const std::size_t value = sizeof...(Types);
1277
+ };
1278
+ ```
1279
+
1280
+ — *end example*]
1281
+
1282
+ The result of `sizeof` and `sizeof...` is a prvalue of type
1283
+ `std::size_t`.
1284
+
1285
+ [*Note 3*: A `sizeof` expression is an integral constant expression
1286
+ [[expr.const]]. The type `std::size_t` is defined in the standard header
1287
+ `<cstddef>` ([[cstddef.syn]], [[support.types.layout]]). — *end note*]
1288
+
1289
+ #### Alignof <a id="expr.alignof">[[expr.alignof]]</a>
1290
+
1291
+ An `alignof` expression yields the alignment requirement of its operand
1292
+ type. The operand shall be a *type-id* representing a complete object
1293
+ type, or an array thereof, or a reference to one of those types.
1294
+
1295
+ The result is a prvalue of type `std::size_t`.
1296
+
1297
+ [*Note 1*: An `alignof` expression is an integral constant expression
1298
+ [[expr.const]]. The type `std::size_t` is defined in the standard header
1299
+ `<cstddef>` ([[cstddef.syn]], [[support.types.layout]]). — *end note*]
1300
+
1301
+ When `alignof` is applied to a reference type, the result is the
1302
+ alignment of the referenced type. When `alignof` is applied to an array
1303
+ type, the result is the alignment of the element type.
1304
+
1305
+ #### `noexcept` operator <a id="expr.unary.noexcept">[[expr.unary.noexcept]]</a>
1306
+
1307
+ The `noexcept` operator determines whether the evaluation of its
1308
+ operand, which is an unevaluated operand [[expr.prop]], can throw an
1309
+ exception [[except.throw]].
1310
+
1311
+ ``` bnf
1312
+ noexcept-expression:
1313
+ noexcept '(' expression ')'
1314
+ ```
1315
+
1316
+ The result of the `noexcept` operator is a prvalue of type `bool`.
1317
+
1318
+ [*Note 1*: A *noexcept-expression* is an integral constant expression
1319
+ [[expr.const]]. — *end note*]
1320
+
1321
+ The result of the `noexcept` operator is `true` unless the *expression*
1322
+ is potentially-throwing [[except.spec]].
1323
+
1324
+ #### New <a id="expr.new">[[expr.new]]</a>
1325
+
1326
+ The *new-expression* attempts to create an object of the *type-id*
1327
+ [[dcl.name]] or *new-type-id* to which it is applied. The type of that
1328
+ object is the *allocated type*. This type shall be a complete object
1329
+ type, but not an abstract class type or array thereof (
1330
+ [[intro.object]], [[basic.types]], [[class.abstract]]).
1331
+
1332
+ [*Note 1*: Because references are not objects, references cannot be
1333
+ created by *new-expression*s. — *end note*]
1334
+
1335
+ [*Note 2*: The *type-id* may be a cv-qualified type, in which case the
1336
+ object created by the *new-expression* has a cv-qualified
1337
+ type. — *end note*]
1338
+
1339
+ ``` bnf
1340
+ new-expression:
1341
+ '::'ₒₚₜ new new-placementₒₚₜ new-type-id new-initializerₒₚₜ
1342
+ '::'ₒₚₜ new new-placementₒₚₜ '(' type-id ')' new-initializerₒₚₜ
1343
+ ```
1344
+
1345
+ ``` bnf
1346
+ new-placement:
1347
+ '(' expression-list ')'
1348
+ ```
1349
+
1350
+ ``` bnf
1351
+ new-type-id:
1352
+ type-specifier-seq new-declaratorₒₚₜ
1353
+ ```
1354
+
1355
+ ``` bnf
1356
+ new-declarator:
1357
+ ptr-operator new-declaratorₒₚₜ
1358
+ noptr-new-declarator
1359
+ ```
1360
+
1361
+ ``` bnf
1362
+ noptr-new-declarator:
1363
+ '[' expressionₒₚₜ ']' attribute-specifier-seqₒₚₜ
1364
+ noptr-new-declarator '[' constant-expression ']' attribute-specifier-seqₒₚₜ
1365
+ ```
1366
+
1367
+ ``` bnf
1368
+ new-initializer:
1369
+ '(' expression-listₒₚₜ ')'
1370
+ braced-init-list
1371
+ ```
1372
+
1373
+ If a placeholder type [[dcl.spec.auto]] appears in the
1374
+ *type-specifier-seq* of a *new-type-id* or *type-id* of a
1375
+ *new-expression*, the allocated type is deduced as follows: Let *init*
1376
+ be the *new-initializer*, if any, and `T` be the *new-type-id* or
1377
+ *type-id* of the *new-expression*, then the allocated type is the type
1378
+ deduced for the variable `x` in the invented declaration
1379
+ [[dcl.spec.auto]]:
1380
+
1381
+ ``` cpp
1382
+ T x init ;
1383
+ ```
1384
+
1385
+ [*Example 1*:
1386
+
1387
+ ``` cpp
1388
+ new auto(1); // allocated type is int
1389
+ auto x = new auto('a'); // allocated type is char, x is of type char*
1390
+
1391
+ template<class T> struct A { A(T, T); };
1392
+ auto y = new A{1, 2}; // allocated type is A<int>
1393
+ ```
1394
+
1395
+ — *end example*]
1396
+
1397
+ The *new-type-id* in a *new-expression* is the longest possible sequence
1398
+ of *new-declarator*s.
1399
+
1400
+ [*Note 3*: This prevents ambiguities between the declarator operators
1401
+ `&`, `&&`, `*`, and `[]` and their expression
1402
+ counterparts. — *end note*]
1403
+
1404
+ [*Example 2*:
1405
+
1406
+ ``` cpp
1407
+ new int * i; // syntax error: parsed as (new int*) i, not as (new int)*i
1408
+ ```
1409
+
1410
+ The `*` is the pointer declarator and not the multiplication operator.
1411
+
1412
+ — *end example*]
1413
+
1414
+ [*Note 4*:
1415
+
1416
+ Parentheses in a *new-type-id* of a *new-expression* can have surprising
1417
+ effects.
1418
+
1419
+ [*Example 3*:
1420
+
1421
+ ``` cpp
1422
+ new int(*[10])(); // error
1423
+ ```
1424
+
1425
+ is ill-formed because the binding is
1426
+
1427
+ ``` cpp
1428
+ (new int) (*[10])(); // error
1429
+ ```
1430
+
1431
+ Instead, the explicitly parenthesized version of the `new` operator can
1432
+ be used to create objects of compound types [[basic.compound]]:
1433
+
1434
+ ``` cpp
1435
+ new (int (*[10])());
1436
+ ```
1437
+
1438
+ allocates an array of `10` pointers to functions (taking no argument and
1439
+ returning `int`).
1440
+
1441
+ — *end example*]
1442
+
1443
+ — *end note*]
1444
+
1445
+ Objects created by a *new-expression* have dynamic storage duration
1446
+ [[basic.stc.dynamic]].
1447
+
1448
+ [*Note 5*: The lifetime of such an object is not necessarily
1449
+ restricted to the scope in which it is created. — *end note*]
1450
+
1451
+ When the allocated object is not an array, the result of the
1452
+ *new-expression* is a pointer to the object created.
1453
+
1454
+ When the allocated object is an array (that is, the
1455
+ *noptr-new-declarator* syntax is used or the *new-type-id* or *type-id*
1456
+ denotes an array type), the *new-expression* yields a pointer to the
1457
+ initial element (if any) of the array.
1458
+
1459
+ [*Note 6*: Both `new int` and `new int[10]` have type `int*` and the
1460
+ type of `new int[i][10]` is `int (*)[10]` — *end note*]
1461
+
1462
+ The *attribute-specifier-seq* in a *noptr-new-declarator* appertains to
1463
+ the associated array type.
1464
+
1465
+ Every *constant-expression* in a *noptr-new-declarator* shall be a
1466
+ converted constant expression [[expr.const]] of type `std::size_t` and
1467
+ its value shall be greater than zero.
1468
+
1469
+ [*Example 4*: Given the definition `int n = 42`, `new float[n][5]` is
1470
+ well-formed (because `n` is the *expression* of a
1471
+ *noptr-new-declarator*), but `new float[5][n]` is ill-formed (because
1472
+ `n` is not a constant expression). — *end example*]
1473
+
1474
+ If the *type-id* or *new-type-id* denotes an array type of unknown bound
1475
+ [[dcl.array]], the *new-initializer* shall not be omitted; the allocated
1476
+ object is an array with `n` elements, where `n` is determined from the
1477
+ number of initial elements supplied in the *new-initializer* (
1478
+ [[dcl.init.aggr]], [[dcl.init.string]]).
1479
+
1480
+ If the *expression* in a *noptr-new-declarator* is present, it is
1481
+ implicitly converted to `std::size_t`. The *expression* is erroneous if:
1482
+
1483
+ - the expression is of non-class type and its value before converting to
1484
+ `std::size_t` is less than zero;
1485
+ - the expression is of class type and its value before application of
1486
+ the second standard conversion [[over.ics.user]][^23] is less than
1487
+ zero;
1488
+ - its value is such that the size of the allocated object would exceed
1489
+ the *implementation-defined* limit [[implimits]]; or
1490
+ - the *new-initializer* is a *braced-init-list* and the number of array
1491
+ elements for which initializers are provided (including the
1492
+ terminating `'\0'` in a *string-literal* [[lex.string]]) exceeds the
1493
+ number of elements to initialize.
1494
+
1495
+ If the *expression* is erroneous after converting to `std::size_t`:
1496
+
1497
+ - if the *expression* is a core constant expression, the program is
1498
+ ill-formed;
1499
+ - otherwise, an allocation function is not called; instead
1500
+ - if the allocation function that would have been called has a
1501
+ non-throwing exception specification [[except.spec]], the value of
1502
+ the *new-expression* is the null pointer value of the required
1503
+ result type;
1504
+ - otherwise, the *new-expression* terminates by throwing an exception
1505
+ of a type that would match a handler [[except.handle]] of type
1506
+ `std::bad_array_new_length` [[new.badlength]].
1507
+
1508
+ When the value of the *expression* is zero, the allocation function is
1509
+ called to allocate an array with no elements.
1510
+
1511
+ A *new-expression* may obtain storage for the object by calling an
1512
+ allocation function [[basic.stc.dynamic.allocation]]. If the
1513
+ *new-expression* terminates by throwing an exception, it may release
1514
+ storage by calling a deallocation function
1515
+ [[basic.stc.dynamic.deallocation]]. If the allocated type is a non-array
1516
+ type, the allocation function’s name is `operator new` and the
1517
+ deallocation function’s name is `operator delete`. If the allocated type
1518
+ is an array type, the allocation function’s name is `operator new[]` and
1519
+ the deallocation function’s name is `operator delete[]`.
1520
+
1521
+ [*Note 7*: An implementation is required to provide default definitions
1522
+ for the global allocation functions ([[basic.stc.dynamic]],
1523
+ [[new.delete.single]], [[new.delete.array]]). A C++ program can provide
1524
+ alternative definitions of these functions [[replacement.functions]]
1525
+ and/or class-specific versions [[class.free]]. The set of allocation and
1526
+ deallocation functions that may be called by a *new-expression* may
1527
+ include functions that do not perform allocation or deallocation; for
1528
+ example, see [[new.delete.placement]]. — *end note*]
1529
+
1530
+ If the *new-expression* begins with a unary `::` operator, the
1531
+ allocation function’s name is looked up in the global scope. Otherwise,
1532
+ if the allocated type is a class type `T` or array thereof, the
1533
+ allocation function’s name is looked up in the scope of `T`. If this
1534
+ lookup fails to find the name, or if the allocated type is not a class
1535
+ type, the allocation function’s name is looked up in the global scope.
1536
+
1537
+ An implementation is allowed to omit a call to a replaceable global
1538
+ allocation function ([[new.delete.single]], [[new.delete.array]]). When
1539
+ it does so, the storage is instead provided by the implementation or
1540
+ provided by extending the allocation of another *new-expression*.
1541
+
1542
+ During an evaluation of a constant expression, a call to an allocation
1543
+ function is always omitted.
1544
+
1545
+ [*Note 8*: Only *new-expression*s that would otherwise result in a call
1546
+ to a replaceable global allocation function can be evaluated in constant
1547
+ expressions [[expr.const]]. — *end note*]
1548
+
1549
+ The implementation may extend the allocation of a *new-expression* `e1`
1550
+ to provide storage for a *new-expression* `e2` if the following would be
1551
+ true were the allocation not extended:
1552
+
1553
+ - the evaluation of `e1` is sequenced before the evaluation of `e2`, and
1554
+ - `e2` is evaluated whenever `e1` obtains storage, and
1555
+ - both `e1` and `e2` invoke the same replaceable global allocation
1556
+ function, and
1557
+ - if the allocation function invoked by `e1` and `e2` is throwing, any
1558
+ exceptions thrown in the evaluation of either `e1` or `e2` would be
1559
+ first caught in the same handler, and
1560
+ - the pointer values produced by `e1` and `e2` are operands to evaluated
1561
+ *delete-expression*s, and
1562
+ - the evaluation of `e2` is sequenced before the evaluation of the
1563
+ *delete-expression* whose operand is the pointer value produced by
1564
+ `e1`.
1565
+
1566
+ [*Example 5*:
1567
+
1568
+ ``` cpp
1569
+ void can_merge(int x) {
1570
+ // These allocations are safe for merging:
1571
+ std::unique_ptr<char[]> a{new (std::nothrow) char[8]};
1572
+ std::unique_ptr<char[]> b{new (std::nothrow) char[8]};
1573
+ std::unique_ptr<char[]> c{new (std::nothrow) char[x]};
1574
+
1575
+ g(a.get(), b.get(), c.get());
1576
+ }
1577
+
1578
+ void cannot_merge(int x) {
1579
+ std::unique_ptr<char[]> a{new char[8]};
1580
+ try {
1581
+ // Merging this allocation would change its catch handler.
1582
+ std::unique_ptr<char[]> b{new char[x]};
1583
+ } catch (const std::bad_alloc& e) {
1584
+ std::cerr << "Allocation failed: " << e.what() << std::endl;
1585
+ throw;
1586
+ }
1587
+ }
1588
+ ```
1589
+
1590
+ — *end example*]
1591
+
1592
+ When a *new-expression* calls an allocation function and that allocation
1593
+ has not been extended, the *new-expression* passes the amount of space
1594
+ requested to the allocation function as the first argument of type
1595
+ `std::size_t`. That argument shall be no less than the size of the
1596
+ object being created; it may be greater than the size of the object
1597
+ being created only if the object is an array and the allocation function
1598
+ is not a non-allocating form [[new.delete.placement]]. For arrays of
1599
+ `char`, `unsigned char`, and `std::byte`, the difference between the
1600
+ result of the *new-expression* and the address returned by the
1601
+ allocation function shall be an integral multiple of the strictest
1602
+ fundamental alignment requirement [[basic.align]] of any object type
1603
+ whose size is no greater than the size of the array being created.
1604
+
1605
+ [*Note 9*: Because allocation functions are assumed to return pointers
1606
+ to storage that is appropriately aligned for objects of any type with
1607
+ fundamental alignment, this constraint on array allocation overhead
1608
+ permits the common idiom of allocating character arrays into which
1609
+ objects of other types will later be placed. — *end note*]
1610
+
1611
+ When a *new-expression* calls an allocation function and that allocation
1612
+ has been extended, the size argument to the allocation call shall be no
1613
+ greater than the sum of the sizes for the omitted calls as specified
1614
+ above, plus the size for the extended call had it not been extended,
1615
+ plus any padding necessary to align the allocated objects within the
1616
+ allocated memory.
1617
+
1618
+ The *new-placement* syntax is used to supply additional arguments to an
1619
+ allocation function; such an expression is called a *placement
1620
+ *new-expression**.
1621
+
1622
+ Overload resolution is performed on a function call created by
1623
+ assembling an argument list. The first argument is the amount of space
1624
+ requested, and has type `std::size_t`. If the type of the allocated
1625
+ object has new-extended alignment, the next argument is the type’s
1626
+ alignment, and has type `std::align_val_t`. If the *new-placement*
1627
+ syntax is used, the *initializer-clause*s in its *expression-list* are
1628
+ the succeeding arguments. If no matching function is found then
1629
+
1630
+ - if the allocated object type has new-extended alignment, the alignment
1631
+ argument is removed from the argument list;
1632
+ - otherwise, an argument that is the type’s alignment and has type
1633
+ `std::align_val_t` is added into the argument list immediately after
1634
+ the first argument;
1635
+
1636
+ and then overload resolution is performed again.
1637
+
1638
+ [*Example 6*:
1639
+
1640
+ - `new T` results in one of the following calls:
1641
+ ``` cpp
1642
+ operator new(sizeof(T))
1643
+ operator new(sizeof(T), std::align_val_t(alignof(T)))
1644
+ ```
1645
+ - `new(2,f) T` results in one of the following calls:
1646
+ ``` cpp
1647
+ operator new(sizeof(T), 2, f)
1648
+ operator new(sizeof(T), std::align_val_t(alignof(T)), 2, f)
1649
+ ```
1650
+ - `new T[5]` results in one of the following calls:
1651
+ ``` cpp
1652
+ operator new[](sizeof(T) * 5 + x)
1653
+ operator new[](sizeof(T) * 5 + x, std::align_val_t(alignof(T)))
1654
+ ```
1655
+ - `new(2,f) T[5]` results in one of the following calls:
1656
+ ``` cpp
1657
+ operator new[](sizeof(T) * 5 + x, 2, f)
1658
+ operator new[](sizeof(T) * 5 + x, std::align_val_t(alignof(T)), 2, f)
1659
+ ```
1660
+
1661
+ Here, each instance of `x` is a non-negative unspecified value
1662
+ representing array allocation overhead; the result of the
1663
+ *new-expression* will be offset by this amount from the value returned
1664
+ by `operator new[]`. This overhead may be applied in all array
1665
+ *new-expression*s, including those referencing a placement allocation
1666
+ function, except when referencing the library function
1667
+ `operator new[](std::size_t, void*)`. The amount of overhead may vary
1668
+ from one invocation of `new` to another.
1669
+
1670
+ — *end example*]
1671
+
1672
+ [*Note 10*: Unless an allocation function has a non-throwing exception
1673
+ specification [[except.spec]], it indicates failure to allocate storage
1674
+ by throwing a `std::bad_alloc` exception (
1675
+ [[basic.stc.dynamic.allocation]], [[except]], [[bad.alloc]]); it returns
1676
+ a non-null pointer otherwise. If the allocation function has a
1677
+ non-throwing exception specification, it returns null to indicate
1678
+ failure to allocate storage and a non-null pointer
1679
+ otherwise. — *end note*]
1680
+
1681
+ If the allocation function is a non-allocating form
1682
+ [[new.delete.placement]] that returns null, the behavior is undefined.
1683
+ Otherwise, if the allocation function returns null, initialization shall
1684
+ not be done, the deallocation function shall not be called, and the
1685
+ value of the *new-expression* shall be null.
1686
+
1687
+ [*Note 11*: When the allocation function returns a value other than
1688
+ null, it must be a pointer to a block of storage in which space for the
1689
+ object has been reserved. The block of storage is assumed to be
1690
+ appropriately aligned and of the requested size. The address of the
1691
+ created object will not necessarily be the same as that of the block if
1692
+ the object is an array. — *end note*]
1693
+
1694
+ A *new-expression* that creates an object of type `T` initializes that
1695
+ object as follows:
1696
+
1697
+ - If the *new-initializer* is omitted, the object is default-initialized
1698
+ [[dcl.init]]. \[*Note 12*: If no initialization is performed, the
1699
+ object has an indeterminate value. — *end note*]
1700
+ - Otherwise, the *new-initializer* is interpreted according to the
1701
+ initialization rules of  [[dcl.init]] for direct-initialization.
1702
+
1703
+ The invocation of the allocation function is sequenced before the
1704
+ evaluations of expressions in the *new-initializer*. Initialization of
1705
+ the allocated object is sequenced before the value computation of the
1706
+ *new-expression*.
1707
+
1708
+ If the *new-expression* creates an object or an array of objects of
1709
+ class type, access and ambiguity control are done for the allocation
1710
+ function, the deallocation function [[class.free]], and the constructor
1711
+ [[class.ctor]] selected for the initialization (if any). If the
1712
+ *new-expression* creates an array of objects of class type, the
1713
+ destructor is potentially invoked [[class.dtor]].
1714
+
1715
+ If any part of the object initialization described above[^24] terminates
1716
+ by throwing an exception and a suitable deallocation function can be
1717
+ found, the deallocation function is called to free the memory in which
1718
+ the object was being constructed, after which the exception continues to
1719
+ propagate in the context of the *new-expression*. If no unambiguous
1720
+ matching deallocation function can be found, propagating the exception
1721
+ does not cause the object’s memory to be freed.
1722
+
1723
+ [*Note 13*: This is appropriate when the called allocation function
1724
+ does not allocate memory; otherwise, it is likely to result in a memory
1725
+ leak. — *end note*]
1726
+
1727
+ If the *new-expression* begins with a unary `::` operator, the
1728
+ deallocation function’s name is looked up in the global scope.
1729
+ Otherwise, if the allocated type is a class type `T` or an array
1730
+ thereof, the deallocation function’s name is looked up in the scope of
1731
+ `T`. If this lookup fails to find the name, or if the allocated type is
1732
+ not a class type or array thereof, the deallocation function’s name is
1733
+ looked up in the global scope.
1734
+
1735
+ A declaration of a placement deallocation function matches the
1736
+ declaration of a placement allocation function if it has the same number
1737
+ of parameters and, after parameter transformations [[dcl.fct]], all
1738
+ parameter types except the first are identical. If the lookup finds a
1739
+ single matching deallocation function, that function will be called;
1740
+ otherwise, no deallocation function will be called. If the lookup finds
1741
+ a usual deallocation function and that function, considered as a
1742
+ placement deallocation function, would have been selected as a match for
1743
+ the allocation function, the program is ill-formed. For a non-placement
1744
+ allocation function, the normal deallocation function lookup is used to
1745
+ find the matching deallocation function [[expr.delete]].
1746
+
1747
+ [*Example 7*:
1748
+
1749
+ ``` cpp
1750
+ struct S {
1751
+ // Placement allocation function:
1752
+ static void* operator new(std::size_t, std::size_t);
1753
+
1754
+ // Usual (non-placement) deallocation function:
1755
+ static void operator delete(void*, std::size_t);
1756
+ };
1757
+
1758
+ S* p = new (0) S; // error: non-placement deallocation function matches
1759
+ // placement allocation function
1760
+ ```
1761
+
1762
+ — *end example*]
1763
+
1764
+ If a *new-expression* calls a deallocation function, it passes the value
1765
+ returned from the allocation function call as the first argument of type
1766
+ `void*`. If a placement deallocation function is called, it is passed
1767
+ the same additional arguments as were passed to the placement allocation
1768
+ function, that is, the same arguments as those specified with the
1769
+ *new-placement* syntax. If the implementation is allowed to introduce a
1770
+ temporary object or make a copy of any argument as part of the call to
1771
+ the allocation function, it is unspecified whether the same object is
1772
+ used in the call to both the allocation and deallocation functions.
1773
+
1774
+ #### Delete <a id="expr.delete">[[expr.delete]]</a>
1775
+
1776
+ The *delete-expression* operator destroys a most derived object
1777
+ [[intro.object]] or array created by a *new-expression*.
1778
+
1779
+ ``` bnf
1780
+ delete-expression:
1781
+ '::'ₒₚₜ delete cast-expression
1782
+ '::'ₒₚₜ delete '[' ']' cast-expression
1783
+ ```
1784
+
1785
+ The first alternative is a *single-object delete expression*, and the
1786
+ second is an *array delete expression*. Whenever the `delete` keyword is
1787
+ immediately followed by empty square brackets, it shall be interpreted
1788
+ as the second alternative.[^25] The operand shall be of pointer to
1789
+ object type or of class type. If of class type, the operand is
1790
+ contextually implicitly converted [[conv]] to a pointer to object
1791
+ type.[^26] The *delete-expression*’s result has type `void`.
1792
+
1793
+ If the operand has a class type, the operand is converted to a pointer
1794
+ type by calling the above-mentioned conversion function, and the
1795
+ converted operand is used in place of the original operand for the
1796
+ remainder of this subclause. In a single-object delete expression, the
1797
+ value of the operand of `delete` may be a null pointer value, a pointer
1798
+ to a non-array object created by a previous *new-expression*, or a
1799
+ pointer to a subobject [[intro.object]] representing a base class of
1800
+ such an object [[class.derived]]. If not, the behavior is undefined. In
1801
+ an array delete expression, the value of the operand of `delete` may be
1802
+ a null pointer value or a pointer value that resulted from a previous
1803
+ array *new-expression*.[^27] If not, the behavior is undefined.
1804
+
1805
+ [*Note 1*: This means that the syntax of the *delete-expression* must
1806
+ match the type of the object allocated by `new`, not the syntax of the
1807
+ *new-expression*. — *end note*]
1808
+
1809
+ [*Note 2*: A pointer to a `const` type can be the operand of a
1810
+ *delete-expression*; it is not necessary to cast away the constness
1811
+ [[expr.const.cast]] of the pointer expression before it is used as the
1812
+ operand of the *delete-expression*. — *end note*]
1813
+
1814
+ In a single-object delete expression, if the static type of the object
1815
+ to be deleted is different from its dynamic type and the selected
1816
+ deallocation function (see below) is not a destroying operator delete,
1817
+ the static type shall be a base class of the dynamic type of the object
1818
+ to be deleted and the static type shall have a virtual destructor or the
1819
+ behavior is undefined. In an array delete expression, if the dynamic
1820
+ type of the object to be deleted differs from its static type, the
1821
+ behavior is undefined.
1822
+
1823
+ The *cast-expression* in a *delete-expression* shall be evaluated
1824
+ exactly once.
1825
+
1826
+ If the object being deleted has incomplete class type at the point of
1827
+ deletion and the complete class has a non-trivial destructor or a
1828
+ deallocation function, the behavior is undefined.
1829
+
1830
+ If the value of the operand of the *delete-expression* is not a null
1831
+ pointer value and the selected deallocation function (see below) is not
1832
+ a destroying operator delete, the *delete-expression* will invoke the
1833
+ destructor (if any) for the object or the elements of the array being
1834
+ deleted. In the case of an array, the elements will be destroyed in
1835
+ order of decreasing address (that is, in reverse order of the completion
1836
+ of their constructor; see  [[class.base.init]]).
1837
+
1838
+ If the value of the operand of the *delete-expression* is not a null
1839
+ pointer value, then:
1840
+
1841
+ - If the allocation call for the *new-expression* for the object to be
1842
+ deleted was not omitted and the allocation was not extended
1843
+ [[expr.new]], the *delete-expression* shall call a deallocation
1844
+ function [[basic.stc.dynamic.deallocation]]. The value returned from
1845
+ the allocation call of the *new-expression* shall be passed as the
1846
+ first argument to the deallocation function.
1847
+ - Otherwise, if the allocation was extended or was provided by extending
1848
+ the allocation of another *new-expression*, and the
1849
+ *delete-expression* for every other pointer value produced by a
1850
+ *new-expression* that had storage provided by the extended
1851
+ *new-expression* has been evaluated, the *delete-expression* shall
1852
+ call a deallocation function. The value returned from the allocation
1853
+ call of the extended *new-expression* shall be passed as the first
1854
+ argument to the deallocation function.
1855
+ - Otherwise, the *delete-expression* will not call a deallocation
1856
+ function.
1857
+
1858
+ [*Note 3*: The deallocation function is called regardless of whether
1859
+ the destructor for the object or some element of the array throws an
1860
+ exception. — *end note*]
1861
+
1862
+ If the value of the operand of the *delete-expression* is a null pointer
1863
+ value, it is unspecified whether a deallocation function will be called
1864
+ as described above.
1865
+
1866
+ [*Note 4*: An implementation provides default definitions of the global
1867
+ deallocation functions `operator delete` for non-arrays
1868
+ [[new.delete.single]] and `operator delete[]` for arrays
1869
+ [[new.delete.array]]. A C++ program can provide alternative definitions
1870
+ of these functions [[replacement.functions]], and/or class-specific
1871
+ versions [[class.free]]. — *end note*]
1872
+
1873
+ When the keyword `delete` in a *delete-expression* is preceded by the
1874
+ unary `::` operator, the deallocation function’s name is looked up in
1875
+ global scope. Otherwise, the lookup considers class-specific
1876
+ deallocation functions [[class.free]]. If no class-specific deallocation
1877
+ function is found, the deallocation function’s name is looked up in
1878
+ global scope.
1879
+
1880
+ If deallocation function lookup finds more than one usual deallocation
1881
+ function, the function to be called is selected as follows:
1882
+
1883
+ - If any of the deallocation functions is a destroying operator delete,
1884
+ all deallocation functions that are not destroying operator deletes
1885
+ are eliminated from further consideration.
1886
+ - If the type has new-extended alignment, a function with a parameter of
1887
+ type `std::align_val_t` is preferred; otherwise a function without
1888
+ such a parameter is preferred. If any preferred functions are found,
1889
+ all non-preferred functions are eliminated from further consideration.
1890
+ - If exactly one function remains, that function is selected and the
1891
+ selection process terminates.
1892
+ - If the deallocation functions have class scope, the one without a
1893
+ parameter of type `std::size_t` is selected.
1894
+ - If the type is complete and if, for an array delete expression only,
1895
+ the operand is a pointer to a class type with a non-trivial destructor
1896
+ or a (possibly multi-dimensional) array thereof, the function with a
1897
+ parameter of type `std::size_t` is selected.
1898
+ - Otherwise, it is unspecified whether a deallocation function with a
1899
+ parameter of type `std::size_t` is selected.
1900
+
1901
+ For a single-object delete expression, the deleted object is the object
1902
+ denoted by the operand if its static type does not have a virtual
1903
+ destructor, and its most-derived object otherwise.
1904
+
1905
+ [*Note 5*: If the deallocation function is not a destroying operator
1906
+ delete and the deleted object is not the most derived object in the
1907
+ former case, the behavior is undefined, as stated above. — *end note*]
1908
+
1909
+ For an array delete expression, the deleted object is the array object.
1910
+ When a *delete-expression* is executed, the selected deallocation
1911
+ function shall be called with the address of the deleted object in a
1912
+ single-object delete expression, or the address of the deleted object
1913
+ suitably adjusted for the array allocation overhead [[expr.new]] in an
1914
+ array delete expression, as its first argument.
1915
+
1916
+ [*Note 6*: Any cv-qualifiers in the type of the deleted object are
1917
+ ignored when forming this argument. — *end note*]
1918
+
1919
+ If a destroying operator delete is used, an unspecified value is passed
1920
+ as the argument corresponding to the parameter of type
1921
+ `std::destroying_delete_t`. If a deallocation function with a parameter
1922
+ of type `std::align_val_t` is used, the alignment of the type of the
1923
+ deleted object is passed as the corresponding argument. If a
1924
+ deallocation function with a parameter of type `std::size_t` is used,
1925
+ the size of the deleted object in a single-object delete expression, or
1926
+ of the array plus allocation overhead in an array delete expression, is
1927
+ passed as the corresponding argument.
1928
+
1929
+ [*Note 7*: If this results in a call to a replaceable deallocation
1930
+ function, and either the first argument was not the result of a prior
1931
+ call to a replaceable allocation function or the second or third
1932
+ argument was not the corresponding argument in said call, the behavior
1933
+ is undefined ([[new.delete.single]],
1934
+ [[new.delete.array]]). — *end note*]
1935
+
1936
+ Access and ambiguity control are done for both the deallocation function
1937
+ and the destructor ([[class.dtor]], [[class.free]]).
1938
+
1939
+ ### Explicit type conversion (cast notation) <a id="expr.cast">[[expr.cast]]</a>
1940
+
1941
+ The result of the expression `(T)` *cast-expression* is of type `T`. The
1942
+ result is an lvalue if `T` is an lvalue reference type or an rvalue
1943
+ reference to function type and an xvalue if `T` is an rvalue reference
1944
+ to object type; otherwise the result is a prvalue.
1945
+
1946
+ [*Note 1*: If `T` is a non-class type that is cv-qualified, the
1947
+ *cv-qualifier*s are discarded when determining the type of the resulting
1948
+ prvalue; see [[expr.prop]]. — *end note*]
1949
+
1950
+ An explicit type conversion can be expressed using functional notation
1951
+ [[expr.type.conv]], a type conversion operator (`dynamic_cast`,
1952
+ `static_cast`, `reinterpret_cast`, `const_cast`), or the *cast*
1953
+ notation.
1954
+
1955
+ ``` bnf
1956
+ cast-expression:
1957
+ unary-expression
1958
+ '(' type-id ')' cast-expression
1959
+ ```
1960
+
1961
+ Any type conversion not mentioned below and not explicitly defined by
1962
+ the user [[class.conv]] is ill-formed.
1963
+
1964
+ The conversions performed by
1965
+
1966
+ - a `const_cast` [[expr.const.cast]],
1967
+ - a `static_cast` [[expr.static.cast]],
1968
+ - a `static_cast` followed by a `const_cast`,
1969
+ - a `reinterpret_cast` [[expr.reinterpret.cast]], or
1970
+ - a `reinterpret_cast` followed by a `const_cast`,
1971
+
1972
+ can be performed using the cast notation of explicit type conversion.
1973
+ The same semantic restrictions and behaviors apply, with the exception
1974
+ that in performing a `static_cast` in the following situations the
1975
+ conversion is valid even if the base class is inaccessible:
1976
+
1977
+ - a pointer to an object of derived class type or an lvalue or rvalue of
1978
+ derived class type may be explicitly converted to a pointer or
1979
+ reference to an unambiguous base class type, respectively;
1980
+ - a pointer to member of derived class type may be explicitly converted
1981
+ to a pointer to member of an unambiguous non-virtual base class type;
1982
+ - a pointer to an object of an unambiguous non-virtual base class type,
1983
+ a glvalue of an unambiguous non-virtual base class type, or a pointer
1984
+ to member of an unambiguous non-virtual base class type may be
1985
+ explicitly converted to a pointer, a reference, or a pointer to member
1986
+ of a derived class type, respectively.
1987
+
1988
+ If a conversion can be interpreted in more than one of the ways listed
1989
+ above, the interpretation that appears first in the list is used, even
1990
+ if a cast resulting from that interpretation is ill-formed. If a
1991
+ conversion can be interpreted in more than one way as a `static_cast`
1992
+ followed by a `const_cast`, the conversion is ill-formed.
1993
+
1994
+ [*Example 1*:
1995
+
1996
+ ``` cpp
1997
+ struct A { };
1998
+ struct I1 : A { };
1999
+ struct I2 : A { };
2000
+ struct D : I1, I2 { };
2001
+ A* foo( D* p ) {
2002
+ return (A*)( p ); // ill-formed static_cast interpretation
2003
+ }
2004
+ ```
2005
+
2006
+ — *end example*]
2007
+
2008
+ The operand of a cast using the cast notation can be a prvalue of type
2009
+ “pointer to incomplete class type”. The destination type of a cast using
2010
+ the cast notation can be “pointer to incomplete class type”. If both the
2011
+ operand and destination types are class types and one or both are
2012
+ incomplete, it is unspecified whether the `static_cast` or the
2013
+ `reinterpret_cast` interpretation is used, even if there is an
2014
+ inheritance relationship between the two classes.
2015
+
2016
+ [*Note 2*: For example, if the classes were defined later in the
2017
+ translation unit, a multi-pass compiler would be permitted to interpret
2018
+ a cast between pointers to the classes as if the class types were
2019
+ complete at the point of the cast. — *end note*]
2020
+
2021
+ ### Pointer-to-member operators <a id="expr.mptr.oper">[[expr.mptr.oper]]</a>
2022
+
2023
+ The pointer-to-member operators `->*` and `.*` group left-to-right.
2024
+
2025
+ ``` bnf
2026
+ pm-expression:
2027
+ cast-expression
2028
+ pm-expression '.*' cast-expression
2029
+ pm-expression '->*' cast-expression
2030
+ ```
2031
+
2032
+ The binary operator `.*` binds its second operand, which shall be of
2033
+ type “pointer to member of `T`” to its first operand, which shall be a
2034
+ glvalue of class `T` or of a class of which `T` is an unambiguous and
2035
+ accessible base class. The result is an object or a function of the type
2036
+ specified by the second operand.
2037
+
2038
+ The binary operator `->*` binds its second operand, which shall be of
2039
+ type “pointer to member of `T`” to its first operand, which shall be of
2040
+ type “pointer to `U`” where `U` is either `T` or a class of which `T` is
2041
+ an unambiguous and accessible base class. The expression `E1->*E2` is
2042
+ converted into the equivalent form `(*(E1)).*E2`.
2043
+
2044
+ Abbreviating *pm-expression*`.*`*cast-expression* as `E1.*E2`, `E1` is
2045
+ called the *object expression*. If the dynamic type of `E1` does not
2046
+ contain the member to which `E2` refers, the behavior is undefined.
2047
+ Otherwise, the expression `E1` is sequenced before the expression `E2`.
2048
+
2049
+ The restrictions on cv-qualification, and the manner in which the
2050
+ cv-qualifiers of the operands are combined to produce the cv-qualifiers
2051
+ of the result, are the same as the rules for `E1.E2` given in 
2052
+ [[expr.ref]].
2053
+
2054
+ [*Note 1*:
2055
+
2056
+ It is not possible to use a pointer to member that refers to a `mutable`
2057
+ member to modify a const class object. For example,
2058
+
2059
+ ``` cpp
2060
+ struct S {
2061
+ S() : i(0) { }
2062
+ mutable int i;
2063
+ };
2064
+ void f()
2065
+ {
2066
+ const S cs;
2067
+ int S::* pm = &S::i; // pm refers to mutable member S::i
2068
+ cs.*pm = 88; // error: cs is a const object
2069
+ }
2070
+ ```
2071
+
2072
+ — *end note*]
2073
+
2074
+ If the result of `.*` or `->*` is a function, then that result can be
2075
+ used only as the operand for the function call operator `()`.
2076
+
2077
+ [*Example 1*:
2078
+
2079
+ ``` cpp
2080
+ (ptr_to_obj->*ptr_to_mfct)(10);
2081
+ ```
2082
+
2083
+ calls the member function denoted by `ptr_to_mfct` for the object
2084
+ pointed to by `ptr_to_obj`.
2085
+
2086
+ — *end example*]
2087
+
2088
+ In a `.*` expression whose object expression is an rvalue, the program
2089
+ is ill-formed if the second operand is a pointer to member function
2090
+ whose *ref-qualifier* is `&`, unless its *cv-qualifier-seq* is `const`.
2091
+ In a `.*` expression whose object expression is an lvalue, the program
2092
+ is ill-formed if the second operand is a pointer to member function
2093
+ whose *ref-qualifier* is `&&`. The result of a `.*` expression whose
2094
+ second operand is a pointer to a data member is an lvalue if the first
2095
+ operand is an lvalue and an xvalue otherwise. The result of a `.*`
2096
+ expression whose second operand is a pointer to a member function is a
2097
+ prvalue. If the second operand is the null member pointer value
2098
+ [[conv.mem]], the behavior is undefined.
2099
+
2100
+ ### Multiplicative operators <a id="expr.mul">[[expr.mul]]</a>
2101
+
2102
+ The multiplicative operators `*`, `/`, and `%` group left-to-right.
2103
+
2104
+ ``` bnf
2105
+ multiplicative-expression:
2106
+ pm-expression
2107
+ multiplicative-expression '*' pm-expression
2108
+ multiplicative-expression '/' pm-expression
2109
+ multiplicative-expression '%' pm-expression
2110
+ ```
2111
+
2112
+ The operands of `*` and `/` shall have arithmetic or unscoped
2113
+ enumeration type; the operands of `%` shall have integral or unscoped
2114
+ enumeration type. The usual arithmetic conversions [[expr.arith.conv]]
2115
+ are performed on the operands and determine the type of the result.
2116
+
2117
+ The binary `*` operator indicates multiplication.
2118
+
2119
+ The binary `/` operator yields the quotient, and the binary `%` operator
2120
+ yields the remainder from the division of the first expression by the
2121
+ second. If the second operand of `/` or `%` is zero the behavior is
2122
+ undefined. For integral operands the `/` operator yields the algebraic
2123
+ quotient with any fractional part discarded;[^28] if the quotient `a/b`
2124
+ is representable in the type of the result, `(a/b)*b + a%b` is equal to
2125
+ `a`; otherwise, the behavior of both `a/b` and `a%b` is undefined.
2126
+
2127
+ ### Additive operators <a id="expr.add">[[expr.add]]</a>
2128
+
2129
+ The additive operators `+` and `-` group left-to-right. The usual
2130
+ arithmetic conversions [[expr.arith.conv]] are performed for operands of
2131
+ arithmetic or enumeration type.
2132
+
2133
+ ``` bnf
2134
+ additive-expression:
2135
+ multiplicative-expression
2136
+ additive-expression '+' multiplicative-expression
2137
+ additive-expression '-' multiplicative-expression
2138
+ ```
2139
+
2140
+ For addition, either both operands shall have arithmetic or unscoped
2141
+ enumeration type, or one operand shall be a pointer to a
2142
+ completely-defined object type and the other shall have integral or
2143
+ unscoped enumeration type.
2144
+
2145
+ For subtraction, one of the following shall hold:
2146
+
2147
+ - both operands have arithmetic or unscoped enumeration type; or
2148
+ - both operands are pointers to cv-qualified or cv-unqualified versions
2149
+ of the same completely-defined object type; or
2150
+ - the left operand is a pointer to a completely-defined object type and
2151
+ the right operand has integral or unscoped enumeration type.
2152
+
2153
+ The result of the binary `+` operator is the sum of the operands. The
2154
+ result of the binary `-` operator is the difference resulting from the
2155
+ subtraction of the second operand from the first.
2156
+
2157
+ When an expression `J` that has integral type is added to or subtracted
2158
+ from an expression `P` of pointer type, the result has the type of `P`.
2159
+
2160
+ - If `P` evaluates to a null pointer value and `J` evaluates to 0, the
2161
+ result is a null pointer value.
2162
+ - Otherwise, if `P` points to an array element i of an array object `x`
2163
+ with n elements [[dcl.array]], [^29] the expressions `P + J` and
2164
+ `J + P` (where `J` has the value j) point to the
2165
+ (possibly-hypothetical) array element i + j of `x` if 0 ≤ i + j ≤ n
2166
+ and the expression `P - J` points to the (possibly-hypothetical) array
2167
+ element i - j of `x` if 0 ≤ i - j ≤ n.
2168
+ - Otherwise, the behavior is undefined.
2169
+
2170
+ When two pointer expressions `P` and `Q` are subtracted, the type of the
2171
+ result is an *implementation-defined* signed integral type; this type
2172
+ shall be the same type that is defined as `std::ptrdiff_t` in the
2173
+ `<cstddef>` header [[support.types.layout]].
2174
+
2175
+ - If `P` and `Q` both evaluate to null pointer values, the result is 0.
2176
+ - Otherwise, if `P` and `Q` point to, respectively, array elements i and
2177
+ j of the same array object `x`, the expression `P - Q` has the value
2178
+ i - j.
2179
+ - Otherwise, the behavior is undefined. \[*Note 1*: If the value i - j
2180
+ is not in the range of representable values of type `std::ptrdiff_t`,
2181
+ the behavior is undefined. — *end note*]
2182
+
2183
+ For addition or subtraction, if the expressions `P` or `Q` have type
2184
+ “pointer to cv `T`”, where `T` and the array element type are not
2185
+ similar [[conv.qual]], the behavior is undefined.
2186
+
2187
+ [*Note 2*: In particular, a pointer to a base class cannot be used for
2188
+ pointer arithmetic when the array contains objects of a derived class
2189
+ type. — *end note*]
2190
+
2191
+ ### Shift operators <a id="expr.shift">[[expr.shift]]</a>
2192
+
2193
+ The shift operators `<<` and `>>` group left-to-right.
2194
+
2195
+ ``` bnf
2196
+ shift-expression:
2197
+ additive-expression
2198
+ shift-expression '<<' additive-expression
2199
+ shift-expression '>>' additive-expression
2200
+ ```
2201
+
2202
+ The operands shall be of integral or unscoped enumeration type and
2203
+ integral promotions are performed. The type of the result is that of the
2204
+ promoted left operand. The behavior is undefined if the right operand is
2205
+ negative, or greater than or equal to the width of the promoted left
2206
+ operand.
2207
+
2208
+ The value of `E1 << E2` is the unique value congruent to `E1` × 2^`E2`
2209
+ modulo 2ᴺ, where N is the width of the type of the result.
2210
+
2211
+ [*Note 1*: `E1` is left-shifted `E2` bit positions; vacated bits are
2212
+ zero-filled. — *end note*]
2213
+
2214
+ The value of `E1 >> E2` is `E1` / 2^`E2`, rounded down.
2215
+
2216
+ [*Note 2*: `E1` is right-shifted `E2` bit positions. Right-shift on
2217
+ signed integral types is an arithmetic right shift, which performs
2218
+ sign-extension. — *end note*]
2219
+
2220
+ The expression `E1` is sequenced before the expression `E2`.
2221
+
2222
+ ### Three-way comparison operator <a id="expr.spaceship">[[expr.spaceship]]</a>
2223
+
2224
+ The three-way comparison operator groups left-to-right.
2225
+
2226
+ ``` bnf
2227
+ compare-expression:
2228
+ shift-expression
2229
+ compare-expression '<=>' shift-expression
2230
+ ```
2231
+
2232
+ The expression `p <=> q` is a prvalue indicating whether `p` is less
2233
+ than, equal to, greater than, or incomparable with `q`.
2234
+
2235
+ If one of the operands is of type `bool` and the other is not, the
2236
+ program is ill-formed.
2237
+
2238
+ If both operands have arithmetic types, or one operand has integral type
2239
+ and the other operand has unscoped enumeration type, the usual
2240
+ arithmetic conversions [[expr.arith.conv]] are applied to the operands.
2241
+ Then:
2242
+
2243
+ - If a narrowing conversion [[dcl.init.list]] is required, other than
2244
+ from an integral type to a floating-point type, the program is
2245
+ ill-formed.
2246
+ - Otherwise, if the operands have integral type, the result is of type
2247
+ `std::strong_ordering`. The result is `std::strong_ordering::equal` if
2248
+ both operands are arithmetically equal, `std::strong_ordering::less`
2249
+ if the first operand is arithmetically less than the second operand,
2250
+ and `std::strong_ordering::greater` otherwise.
2251
+ - Otherwise, the operands have floating-point type, and the result is of
2252
+ type `std::partial_ordering`. The expression `a <=> b` yields
2253
+ `std::partial_ordering::less` if `a` is less than `b`,
2254
+ `std::partial_ordering::greater` if `a` is greater than `b`,
2255
+ `std::partial_ordering::equivalent` if `a` is equivalent to `b`, and
2256
+ `std::partial_ordering::unordered` otherwise.
2257
+
2258
+ If both operands have the same enumeration type `E`, the operator yields
2259
+ the result of converting the operands to the underlying type of `E` and
2260
+ applying `<=>` to the converted operands.
2261
+
2262
+ If at least one of the operands is of pointer type and the other operand
2263
+ is of pointer or array type, array-to-pointer conversions
2264
+ [[conv.array]], pointer conversions [[conv.ptr]], and qualification
2265
+ conversions [[conv.qual]] are performed on both operands to bring them
2266
+ to their composite pointer type [[expr.type]]. After the conversions,
2267
+ the operands shall have the same type.
2268
+
2269
+ [*Note 1*: If both of the operands are arrays, array-to-pointer
2270
+ conversions [[conv.array]] are not applied. — *end note*]
2271
+
2272
+ If the composite pointer type is an object pointer type, `p <=> q` is of
2273
+ type `std::strong_ordering`. If two pointer operands `p` and `q` compare
2274
+ equal [[expr.eq]], `p <=> q` yields `std::strong_ordering::equal`; if
2275
+ `p` and `q` compare unequal, `p <=> q` yields
2276
+ `std::strong_ordering::less` if `q` compares greater than `p` and
2277
+ `std::strong_ordering::greater` if `p` compares greater than `q`
2278
+ [[expr.rel]]. Otherwise, the result is unspecified.
2279
+
2280
+ Otherwise, the program is ill-formed.
2281
+
2282
+ The three comparison category types [[cmp.categories]] (the types
2283
+ `std::strong_ordering`, `std::weak_ordering`, and
2284
+ `std::partial_ordering`) are not predefined; if the header `<compare>`
2285
+ is not imported or included prior to a use of such a class type – even
2286
+ an implicit use in which the type is not named (e.g., via the `auto`
2287
+ specifier [[dcl.spec.auto]] in a defaulted three-way comparison
2288
+ [[class.spaceship]] or use of the built-in operator) – the program is
2289
+ ill-formed.
2290
+
2291
+ ### Relational operators <a id="expr.rel">[[expr.rel]]</a>
2292
+
2293
+ The relational operators group left-to-right.
2294
+
2295
+ [*Example 1*: `a<b<c` means `(a<b)<c` and *not*
2296
+ `(a<b)&&(b<c)`. — *end example*]
2297
+
2298
+ ``` bnf
2299
+ relational-expression:
2300
+ compare-expression
2301
+ relational-expression '<' compare-expression
2302
+ relational-expression '>' compare-expression
2303
+ relational-expression '<=' compare-expression
2304
+ relational-expression '>=' compare-expression
2305
+ ```
2306
+
2307
+ The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
2308
+ function-to-pointer [[conv.func]] standard conversions are performed on
2309
+ the operands. The comparison is deprecated if both operands were of
2310
+ array type prior to these conversions [[depr.array.comp]].
2311
+
2312
+ The converted operands shall have arithmetic, enumeration, or pointer
2313
+ type. The operators `<` (less than), `>` (greater than), `<=` (less than
2314
+ or equal to), and `>=` (greater than or equal to) all yield `false` or
2315
+ `true`. The type of the result is `bool`.
2316
+
2317
+ The usual arithmetic conversions [[expr.arith.conv]] are performed on
2318
+ operands of arithmetic or enumeration type. If both operands are
2319
+ pointers, pointer conversions [[conv.ptr]] and qualification conversions
2320
+ [[conv.qual]] are performed to bring them to their composite pointer
2321
+ type [[expr.type]]. After conversions, the operands shall have the same
2322
+ type.
2323
+
2324
+ The result of comparing unequal pointers to objects [^30] is defined in
2325
+ terms of a partial order consistent with the following rules:
2326
+
2327
+ - If two pointers point to different elements of the same array, or to
2328
+ subobjects thereof, the pointer to the element with the higher
2329
+ subscript is required to compare greater.
2330
+ - If two pointers point to different non-static data members of the same
2331
+ object, or to subobjects of such members, recursively, the pointer to
2332
+ the later declared member is required to compare greater provided the
2333
+ two members have the same access control [[class.access]], neither
2334
+ member is a subobject of zero size, and their class is not a union.
2335
+ - Otherwise, neither pointer is required to compare greater than the
2336
+ other.
2337
+
2338
+ If two operands `p` and `q` compare equal [[expr.eq]], `p<=q` and `p>=q`
2339
+ both yield `true` and `p<q` and `p>q` both yield `false`. Otherwise, if
2340
+ a pointer `p` compares greater than a pointer `q`, `p>=q`, `p>q`,
2341
+ `q<=p`, and `q<p` all yield `true` and `p<=q`, `p<q`, `q>=p`, and `q>p`
2342
+ all yield `false`. Otherwise, the result of each of the operators is
2343
+ unspecified.
2344
+
2345
+ If both operands (after conversions) are of arithmetic or enumeration
2346
+ type, each of the operators shall yield `true` if the specified
2347
+ relationship is true and `false` if it is false.
2348
+
2349
+ ### Equality operators <a id="expr.eq">[[expr.eq]]</a>
2350
+
2351
+ ``` bnf
2352
+ equality-expression:
2353
+ relational-expression
2354
+ equality-expression '==' relational-expression
2355
+ equality-expression '!=' relational-expression
2356
+ ```
2357
+
2358
+ The `==` (equal to) and the `!=` (not equal to) operators group
2359
+ left-to-right. The lvalue-to-rvalue [[conv.lval]], array-to-pointer
2360
+ [[conv.array]], and function-to-pointer [[conv.func]] standard
2361
+ conversions are performed on the operands. The comparison is deprecated
2362
+ if both operands were of array type prior to these conversions
2363
+ [[depr.array.comp]].
2364
+
2365
+ The converted operands shall have arithmetic, enumeration, pointer, or
2366
+ pointer-to-member type, or type `std::nullptr_t`. The operators `==` and
2367
+ `!=` both yield `true` or `false`, i.e., a result of type `bool`. In
2368
+ each case below, the operands shall have the same type after the
2369
+ specified conversions have been applied.
2370
+
2371
+ If at least one of the operands is a pointer, pointer conversions
2372
+ [[conv.ptr]], function pointer conversions [[conv.fctptr]], and
2373
+ qualification conversions [[conv.qual]] are performed on both operands
2374
+ to bring them to their composite pointer type [[expr.type]]. Comparing
2375
+ pointers is defined as follows:
2376
+
2377
+ - If one pointer represents the address of a complete object, and
2378
+ another pointer represents the address one past the last element of a
2379
+ different complete object, [^31] the result of the comparison is
2380
+ unspecified.
2381
+ - Otherwise, if the pointers are both null, both point to the same
2382
+ function, or both represent the same address [[basic.compound]], they
2383
+ compare equal.
2384
+ - Otherwise, the pointers compare unequal.
2385
+
2386
+ If at least one of the operands is a pointer to member,
2387
+ pointer-to-member conversions [[conv.mem]], function pointer conversions
2388
+ [[conv.fctptr]], and qualification conversions [[conv.qual]] are
2389
+ performed on both operands to bring them to their composite pointer type
2390
+ [[expr.type]]. Comparing pointers to members is defined as follows:
2391
+
2392
+ - If two pointers to members are both the null member pointer value,
2393
+ they compare equal.
2394
+ - If only one of two pointers to members is the null member pointer
2395
+ value, they compare unequal.
2396
+ - If either is a pointer to a virtual member function, the result is
2397
+ unspecified.
2398
+ - If one refers to a member of class `C1` and the other refers to a
2399
+ member of a different class `C2`, where neither is a base class of the
2400
+ other, the result is unspecified.
2401
+ \[*Example 1*:
2402
+ ``` cpp
2403
+ struct A {};
2404
+ struct B : A { int x; };
2405
+ struct C : A { int x; };
2406
+
2407
+ int A::*bx = (int(A::*))&B::x;
2408
+ int A::*cx = (int(A::*))&C::x;
2409
+
2410
+ bool b1 = (bx == cx); // unspecified
2411
+ ```
2412
+
2413
+ — *end example*]
2414
+ - If both refer to (possibly different) members of the same union
2415
+ [[class.union]], they compare equal.
2416
+ - Otherwise, two pointers to members compare equal if they would refer
2417
+ to the same member of the same most derived object [[intro.object]] or
2418
+ the same subobject if indirection with a hypothetical object of the
2419
+ associated class type were performed, otherwise they compare unequal.
2420
+ \[*Example 2*:
2421
+ ``` cpp
2422
+ struct B {
2423
+ int f();
2424
+ };
2425
+ struct L : B { };
2426
+ struct R : B { };
2427
+ struct D : L, R { };
2428
+
2429
+ int (B::*pb)() = &B::f;
2430
+ int (L::*pl)() = pb;
2431
+ int (R::*pr)() = pb;
2432
+ int (D::*pdl)() = pl;
2433
+ int (D::*pdr)() = pr;
2434
+ bool x = (pdl == pdr); // false
2435
+ bool y = (pb == pl); // true
2436
+ ```
2437
+
2438
+ — *end example*]
2439
+
2440
+ Two operands of type `std::nullptr_t` or one operand of type
2441
+ `std::nullptr_t` and the other a null pointer constant compare equal.
2442
+
2443
+ If two operands compare equal, the result is `true` for the `==`
2444
+ operator and `false` for the `!=` operator. If two operands compare
2445
+ unequal, the result is `false` for the `==` operator and `true` for the
2446
+ `!=` operator. Otherwise, the result of each of the operators is
2447
+ unspecified.
2448
+
2449
+ If both operands are of arithmetic or enumeration type, the usual
2450
+ arithmetic conversions [[expr.arith.conv]] are performed on both
2451
+ operands; each of the operators shall yield `true` if the specified
2452
+ relationship is true and `false` if it is false.
2453
+
2454
+ ### Bitwise AND operator <a id="expr.bit.and">[[expr.bit.and]]</a>
2455
+
2456
+ ``` bnf
2457
+ and-expression:
2458
+ equality-expression
2459
+ and-expression '&' equality-expression
2460
+ ```
2461
+
2462
+ The `&` operator groups left-to-right. The operands shall be of integral
2463
+ or unscoped enumeration type. The usual arithmetic conversions
2464
+ [[expr.arith.conv]] are performed. Given the coefficients `xᵢ` and `yᵢ`
2465
+ of the base-2 representation [[basic.fundamental]] of the converted
2466
+ operands `x` and `y`, the coefficient `rᵢ` of the base-2 representation
2467
+ of the result `r` is 1 if both `xᵢ` and `yᵢ` are 1, and 0 otherwise.
2468
+
2469
+ [*Note 1*: The result is the bitwise function of the
2470
+ operands. — *end note*]
2471
+
2472
+ ### Bitwise exclusive OR operator <a id="expr.xor">[[expr.xor]]</a>
2473
+
2474
+ ``` bnf
2475
+ exclusive-or-expression:
2476
+ and-expression
2477
+ exclusive-or-expression '^' and-expression
2478
+ ```
2479
+
2480
+ The `^` operator groups left-to-right. The operands shall be of integral
2481
+ or unscoped enumeration type. The usual arithmetic conversions
2482
+ [[expr.arith.conv]] are performed. Given the coefficients `xᵢ` and `yᵢ`
2483
+ of the base-2 representation [[basic.fundamental]] of the converted
2484
+ operands `x` and `y`, the coefficient `rᵢ` of the base-2 representation
2485
+ of the result `r` is 1 if either (but not both) of `xᵢ` and `yᵢ` are 1,
2486
+ and 0 otherwise.
2487
+
2488
+ [*Note 1*: The result is the bitwise exclusive function of the
2489
+ operands. — *end note*]
2490
+
2491
+ ### Bitwise inclusive OR operator <a id="expr.or">[[expr.or]]</a>
2492
+
2493
+ ``` bnf
2494
+ inclusive-or-expression:
2495
+ exclusive-or-expression
2496
+ inclusive-or-expression '|' exclusive-or-expression
2497
+ ```
2498
+
2499
+ The `|` operator groups left-to-right. The operands shall be of integral
2500
+ or unscoped enumeration type. The usual arithmetic conversions
2501
+ [[expr.arith.conv]] are performed. Given the coefficients `xᵢ` and `yᵢ`
2502
+ of the base-2 representation [[basic.fundamental]] of the converted
2503
+ operands `x` and `y`, the coefficient `rᵢ` of the base-2 representation
2504
+ of the result `r` is 1 if at least one of `xᵢ` and `yᵢ` are 1, and 0
2505
+ otherwise.
2506
+
2507
+ [*Note 1*: The result is the bitwise inclusive function of the
2508
+ operands. — *end note*]
2509
+
2510
+ ### Logical AND operator <a id="expr.log.and">[[expr.log.and]]</a>
2511
+
2512
+ ``` bnf
2513
+ logical-and-expression:
2514
+ inclusive-or-expression
2515
+ logical-and-expression '&&' inclusive-or-expression
2516
+ ```
2517
+
2518
+ The `&&` operator groups left-to-right. The operands are both
2519
+ contextually converted to `bool` [[conv]]. The result is `true` if both
2520
+ operands are `true` and `false` otherwise. Unlike `&`, `&&` guarantees
2521
+ left-to-right evaluation: the second operand is not evaluated if the
2522
+ first operand is `false`.
2523
+
2524
+ The result is a `bool`. If the second expression is evaluated, the first
2525
+ expression is sequenced before the second expression
2526
+ [[intro.execution]].
2527
+
2528
+ ### Logical OR operator <a id="expr.log.or">[[expr.log.or]]</a>
2529
+
2530
+ ``` bnf
2531
+ logical-or-expression:
2532
+ logical-and-expression
2533
+ logical-or-expression '||' logical-and-expression
2534
+ ```
2535
+
2536
+ The `||` operator groups left-to-right. The operands are both
2537
+ contextually converted to `bool` [[conv]]. The result is `true` if
2538
+ either of its operands is `true`, and `false` otherwise. Unlike `|`,
2539
+ `||` guarantees left-to-right evaluation; moreover, the second operand
2540
+ is not evaluated if the first operand evaluates to `true`.
2541
+
2542
+ The result is a `bool`. If the second expression is evaluated, the first
2543
+ expression is sequenced before the second expression
2544
+ [[intro.execution]].
2545
+
2546
+ ### Conditional operator <a id="expr.cond">[[expr.cond]]</a>
2547
+
2548
+ ``` bnf
2549
+ conditional-expression:
2550
+ logical-or-expression
2551
+ logical-or-expression '?' expression ':' assignment-expression
2552
+ ```
2553
+
2554
+ Conditional expressions group right-to-left. The first expression is
2555
+ contextually converted to `bool` [[conv]]. It is evaluated and if it is
2556
+ `true`, the result of the conditional expression is the value of the
2557
+ second expression, otherwise that of the third expression. Only one of
2558
+ the second and third expressions is evaluated. The first expression is
2559
+ sequenced before the second or third expression [[intro.execution]].
2560
+
2561
+ If either the second or the third operand has type `void`, one of the
2562
+ following shall hold:
2563
+
2564
+ - The second or the third operand (but not both) is a (possibly
2565
+ parenthesized) *throw-expression* [[expr.throw]]; the result is of the
2566
+ type and value category of the other. The *conditional-expression* is
2567
+ a bit-field if that operand is a bit-field.
2568
+ - Both the second and the third operands have type `void`; the result is
2569
+ of type `void` and is a prvalue. \[*Note 1*: This includes the case
2570
+ where both operands are *throw-expression*s. — *end note*]
2571
+
2572
+ Otherwise, if the second and third operand are glvalue bit-fields of the
2573
+ same value category and of types *cv1* `T` and *cv2* `T`, respectively,
2574
+ the operands are considered to be of type cv `T` for the remainder of
2575
+ this subclause, where cv is the union of *cv1* and *cv2*.
2576
+
2577
+ Otherwise, if the second and third operand have different types and
2578
+ either has (possibly cv-qualified) class type, or if both are glvalues
2579
+ of the same value category and the same type except for
2580
+ cv-qualification, an attempt is made to form an implicit conversion
2581
+ sequence [[over.best.ics]] from each of those operands to the type of
2582
+ the other.
2583
+
2584
+ [*Note 2*: Properties such as access, whether an operand is a
2585
+ bit-field, or whether a conversion function is deleted are ignored for
2586
+ that determination. — *end note*]
2587
+
2588
+ Attempts are made to form an implicit conversion sequence from an
2589
+ operand expression `E1` of type `T1` to a target type related to the
2590
+ type `T2` of the operand expression `E2` as follows:
2591
+
2592
+ - If `E2` is an lvalue, the target type is “lvalue reference to `T2`”,
2593
+ subject to the constraint that in the conversion the reference must
2594
+ bind directly [[dcl.init.ref]] to a glvalue.
2595
+ - If `E2` is an xvalue, the target type is “rvalue reference to `T2`”,
2596
+ subject to the constraint that the reference must bind directly.
2597
+ - If `E2` is a prvalue or if neither of the conversion sequences above
2598
+ can be formed and at least one of the operands has (possibly
2599
+ cv-qualified) class type:
2600
+ - if `T1` and `T2` are the same class type (ignoring cv-qualification)
2601
+ and `T2` is at least as cv-qualified as `T1`, the target type is
2602
+ `T2`,
2603
+ - otherwise, if `T2` is a base class of `T1`, the target type is *cv1*
2604
+ `T2`, where *cv1* denotes the cv-qualifiers of `T1`,
2605
+ - otherwise, the target type is the type that `E2` would have after
2606
+ applying the lvalue-to-rvalue [[conv.lval]], array-to-pointer
2607
+ [[conv.array]], and function-to-pointer [[conv.func]] standard
2608
+ conversions.
2609
+
2610
+ Using this process, it is determined whether an implicit conversion
2611
+ sequence can be formed from the second operand to the target type
2612
+ determined for the third operand, and vice versa. If both sequences can
2613
+ be formed, or one can be formed but it is the ambiguous conversion
2614
+ sequence, the program is ill-formed. If no conversion sequence can be
2615
+ formed, the operands are left unchanged and further checking is
2616
+ performed as described below. Otherwise, if exactly one conversion
2617
+ sequence can be formed, that conversion is applied to the chosen operand
2618
+ and the converted operand is used in place of the original operand for
2619
+ the remainder of this subclause.
2620
+
2621
+ [*Note 3*: The conversion might be ill-formed even if an implicit
2622
+ conversion sequence could be formed. — *end note*]
2623
+
2624
+ If the second and third operands are glvalues of the same value category
2625
+ and have the same type, the result is of that type and value category
2626
+ and it is a bit-field if the second or the third operand is a bit-field,
2627
+ or if both are bit-fields.
2628
+
2629
+ Otherwise, the result is a prvalue. If the second and third operands do
2630
+ not have the same type, and either has (possibly cv-qualified) class
2631
+ type, overload resolution is used to determine the conversions (if any)
2632
+ to be applied to the operands ([[over.match.oper]], [[over.built]]). If
2633
+ the overload resolution fails, the program is ill-formed. Otherwise, the
2634
+ conversions thus determined are applied, and the converted operands are
2635
+ used in place of the original operands for the remainder of this
2636
+ subclause.
2637
+
2638
+ Lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
2639
+ function-to-pointer [[conv.func]] standard conversions are performed on
2640
+ the second and third operands. After those conversions, one of the
2641
+ following shall hold:
2642
+
2643
+ - The second and third operands have the same type; the result is of
2644
+ that type and the result object is initialized using the selected
2645
+ operand.
2646
+ - The second and third operands have arithmetic or enumeration type; the
2647
+ usual arithmetic conversions [[expr.arith.conv]] are performed to
2648
+ bring them to a common type, and the result is of that type.
2649
+ - One or both of the second and third operands have pointer type;
2650
+ pointer conversions [[conv.ptr]], function pointer conversions
2651
+ [[conv.fctptr]], and qualification conversions [[conv.qual]] are
2652
+ performed to bring them to their composite pointer type [[expr.type]].
2653
+ The result is of the composite pointer type.
2654
+ - One or both of the second and third operands have pointer-to-member
2655
+ type; pointer to member conversions [[conv.mem]], function pointer
2656
+ conversions [[conv.fctptr]], and qualification conversions
2657
+ [[conv.qual]] are performed to bring them to their composite pointer
2658
+ type [[expr.type]]. The result is of the composite pointer type.
2659
+ - Both the second and third operands have type `std::nullptr_t` or one
2660
+ has that type and the other is a null pointer constant. The result is
2661
+ of type `std::nullptr_t`.
2662
+
2663
+ ### Yielding a value <a id="expr.yield">[[expr.yield]]</a>
2664
+
2665
+ ``` bnf
2666
+ yield-expression:
2667
+ 'co_yield' assignment-expression
2668
+ 'co_yield' braced-init-list
2669
+ ```
2670
+
2671
+ A *yield-expression* shall appear only within a suspension context of a
2672
+ function [[expr.await]]. Let *e* be the operand of the
2673
+ *yield-expression* and *p* be an lvalue naming the promise object of the
2674
+ enclosing coroutine [[dcl.fct.def.coroutine]], then the
2675
+ *yield-expression* is equivalent to the expression
2676
+ `co_await `*p*`.yield_value(`*e*`)`.
2677
+
2678
+ [*Example 1*:
2679
+
2680
+ ``` cpp
2681
+ template <typename T>
2682
+ struct my_generator {
2683
+ struct promise_type {
2684
+ T current_value;
2685
+ ...
2686
+ auto yield_value(T v) {
2687
+ current_value = std::move(v);
2688
+ return std::suspend_always{};
2689
+ }
2690
+ };
2691
+ struct iterator { ... };
2692
+ iterator begin();
2693
+ iterator end();
2694
+ };
2695
+
2696
+ my_generator<pair<int,int>> g1() {
2697
+ for (int i = i; i < 10; ++i) co_yield {i,i};
2698
+ }
2699
+ my_generator<pair<int,int>> g2() {
2700
+ for (int i = i; i < 10; ++i) co_yield make_pair(i,i);
2701
+ }
2702
+
2703
+ auto f(int x = co_yield 5); // error: yield-expression outside of function suspension context
2704
+ int a[] = { co_yield 1 }; // error: yield-expression outside of function suspension context
2705
+
2706
+ int main() {
2707
+ auto r1 = g1();
2708
+ auto r2 = g2();
2709
+ assert(std::equal(r1.begin(), r1.end(), r2.begin(), r2.end()));
2710
+ }
2711
+ ```
2712
+
2713
+ — *end example*]
2714
+
2715
+ ### Throwing an exception <a id="expr.throw">[[expr.throw]]</a>
2716
+
2717
+ ``` bnf
2718
+ throw-expression:
2719
+ throw assignment-expressionₒₚₜ
2720
+ ```
2721
+
2722
+ A *throw-expression* is of type `void`.
2723
+
2724
+ Evaluating a *throw-expression* with an operand throws an exception
2725
+ [[except.throw]]; the type of the exception object is determined by
2726
+ removing any top-level *cv-qualifier*s from the static type of the
2727
+ operand and adjusting the type from “array of `T`” or function type `T`
2728
+ to “pointer to `T`”.
2729
+
2730
+ A *throw-expression* with no operand rethrows the currently handled
2731
+ exception [[except.handle]]. The exception is reactivated with the
2732
+ existing exception object; no new exception object is created. The
2733
+ exception is no longer considered to be caught.
2734
+
2735
+ [*Example 1*:
2736
+
2737
+ Code that must be executed because of an exception, but cannot
2738
+ completely handle the exception itself, can be written like this:
2739
+
2740
+ ``` cpp
2741
+ try {
2742
+ // ...
2743
+ } catch (...) { // catch all exceptions
2744
+ // respond (partially) to exception
2745
+ throw; // pass the exception to some other handler
2746
+ }
2747
+ ```
2748
+
2749
+ — *end example*]
2750
+
2751
+ If no exception is presently being handled, evaluating a
2752
+ *throw-expression* with no operand calls `std::{}terminate()`
2753
+ [[except.terminate]].
2754
+
2755
+ ### Assignment and compound assignment operators <a id="expr.ass">[[expr.ass]]</a>
2756
+
2757
+ The assignment operator (`=`) and the compound assignment operators all
2758
+ group right-to-left. All require a modifiable lvalue as their left
2759
+ operand; their result is an lvalue referring to the left operand. The
2760
+ result in all cases is a bit-field if the left operand is a bit-field.
2761
+ In all cases, the assignment is sequenced after the value computation of
2762
+ the right and left operands, and before the value computation of the
2763
+ assignment expression. The right operand is sequenced before the left
2764
+ operand. With respect to an indeterminately-sequenced function call, the
2765
+ operation of a compound assignment is a single evaluation.
2766
+
2767
+ [*Note 1*: Therefore, a function call cannot intervene between the
2768
+ lvalue-to-rvalue conversion and the side effect associated with any
2769
+ single compound assignment operator. — *end note*]
2770
+
2771
+ ``` bnf
2772
+ assignment-expression:
2773
+ conditional-expression
2774
+ yield-expression
2775
+ throw-expression
2776
+ logical-or-expression assignment-operator initializer-clause
2777
+ ```
2778
+
2779
+ ``` bnf
2780
+ assignment-operator: one of
2781
+ '= *= /= %= += -= >>= <<= &= ^= |='
2782
+ ```
2783
+
2784
+ In simple assignment (`=`), the object referred to by the left operand
2785
+ is modified [[defns.access]] by replacing its value with the result of
2786
+ the right operand.
2787
+
2788
+ If the right operand is an expression, it is implicitly converted
2789
+ [[conv]] to the cv-unqualified type of the left operand.
2790
+
2791
+ When the left operand of an assignment operator is a bit-field that
2792
+ cannot represent the value of the expression, the resulting value of the
2793
+ bit-field is *implementation-defined*.
2794
+
2795
+ A simple assignment whose left operand is of a volatile-qualified type
2796
+ is deprecated [[depr.volatile.type]] unless the (possibly parenthesized)
2797
+ assignment is a discarded-value expression or an unevaluated operand.
2798
+
2799
+ The behavior of an expression of the form `E1 op= E2` is equivalent to
2800
+ `E1 = E1 op E2` except that `E1` is evaluated only once. Such
2801
+ expressions are deprecated if `E1` has volatile-qualified type; see 
2802
+ [[depr.volatile.type]]. For `+=` and `-=`, `E1` shall either have
2803
+ arithmetic type or be a pointer to a possibly cv-qualified
2804
+ completely-defined object type. In all other cases, `E1` shall have
2805
+ arithmetic type.
2806
+
2807
+ If the value being stored in an object is read via another object that
2808
+ overlaps in any way the storage of the first object, then the overlap
2809
+ shall be exact and the two objects shall have the same type, otherwise
2810
+ the behavior is undefined.
2811
+
2812
+ [*Note 2*: This restriction applies to the relationship between the
2813
+ left and right sides of the assignment operation; it is not a statement
2814
+ about how the target of the assignment may be aliased in general. See 
2815
+ [[basic.lval]]. — *end note*]
2816
+
2817
+ A *braced-init-list* may appear on the right-hand side of
2818
+
2819
+ - an assignment to a scalar, in which case the initializer list shall
2820
+ have at most a single element. The meaning of `x = {v}`, where `T` is
2821
+ the scalar type of the expression `x`, is that of `x = T{v}`. The
2822
+ meaning of `x = {}` is `x = T{}`.
2823
+ - an assignment to an object of class type, in which case the
2824
+ initializer list is passed as the argument to the assignment operator
2825
+ function selected by overload resolution ([[over.ass]],
2826
+ [[over.match]]).
2827
+
2828
+ [*Example 1*:
2829
+
2830
+ ``` cpp
2831
+ complex<double> z;
2832
+ z = { 1,2 }; // meaning z.operator=({1,2\)}
2833
+ z += { 1, 2 }; // meaning z.operator+=({1,2\)}
2834
+ int a, b;
2835
+ a = b = { 1 }; // meaning a=b=1;
2836
+ a = { 1 } = b; // syntax error
2837
+ ```
2838
+
2839
+ — *end example*]
2840
+
2841
+ ### Comma operator <a id="expr.comma">[[expr.comma]]</a>
2842
+
2843
+ The comma operator groups left-to-right.
2844
+
2845
+ ``` bnf
2846
+ expression:
2847
+ assignment-expression
2848
+ expression ',' assignment-expression
2849
+ ```
2850
+
2851
+ A pair of expressions separated by a comma is evaluated left-to-right;
2852
+ the left expression is a discarded-value expression [[expr.prop]]. The
2853
+ left expression is sequenced before the right expression
2854
+ [[intro.execution]]. The type and value of the result are the type and
2855
+ value of the right operand; the result is of the same value category as
2856
+ its right operand, and is a bit-field if its right operand is a
2857
+ bit-field.
2858
+
2859
+ In contexts where comma is given a special meaning,
2860
+
2861
+ [*Example 1*: in lists of arguments to functions [[expr.call]] and
2862
+ lists of initializers [[dcl.init]] — *end example*]
2863
+
2864
+ the comma operator as described in this subclause can appear only in
2865
+ parentheses.
2866
+
2867
+ [*Example 2*:
2868
+
2869
+ ``` cpp
2870
+ f(a, (t=3, t+2), c);
2871
+ ```
2872
+
2873
+ has three arguments, the second of which has the value `5`.
2874
+
2875
+ — *end example*]
2876
+
2877
+ [*Note 1*: A comma expression appearing as the
2878
+ *expr-or-braced-init-list* of a subscripting expression [[expr.sub]] is
2879
+ deprecated; see [[depr.comma.subscript]]. — *end note*]
2880
+