From Jason Turner

[expr.compound]

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

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpx0v65ddf/{from.md → to.md} +797 -520
tmp/tmpx0v65ddf/{from.md → to.md} RENAMED
@@ -13,12 +13,14 @@ postfix-expression:
13
  postfix-expression '(' expression-listₒₚₜ ')'
14
  simple-type-specifier '(' expression-listₒₚₜ ')'
15
  typename-specifier '(' expression-listₒₚₜ ')'
16
  simple-type-specifier braced-init-list
17
  typename-specifier braced-init-list
18
- postfix-expression '.' 'template'ₒₚₜ id-expression
19
- postfix-expression '->' 'template'ₒₚₜ id-expression
 
 
20
  postfix-expression '++'
21
  postfix-expression '--'
22
  dynamic_cast '<' type-id '>' '(' expression ')'
23
  static_cast '<' type-id '>' '(' expression ')'
24
  reinterpret_cast '<' type-id '>' '(' expression ')'
@@ -41,23 +43,24 @@ replacing a `>>` token by two consecutive `>` tokens
41
 
42
  A *subscript expression* is a postfix expression followed by square
43
  brackets containing a possibly empty, comma-separated list of
44
  *initializer-clause*s that constitute the arguments to the subscript
45
  operator. The *postfix-expression* and the initialization of the object
46
- parameter of any applicable subscript operator function is sequenced
47
- before each expression in the *expression-list* and also before any
48
- default argument. The initialization of a non-object parameter of a
49
- subscript operator function `S` [[over.sub]], including every associated
50
- value computation and side effect, is indeterminately sequenced with
51
- respect to that of any other non-object parameter of `S`.
 
52
 
53
  With the built-in subscript operator, an *expression-list* shall be
54
  present, consisting of a single *assignment-expression*. One of the
55
  expressions shall be a glvalue of type “array of `T`” or a prvalue of
56
  type “pointer to `T`” and the other shall be a prvalue of unscoped
57
  enumeration or integral type. The result is of type “`T`”. The type
58
- “`T`” shall be a completely-defined object type.[^11]
59
 
60
  The expression `E1[E2]` is identical (by definition) to `*((E1)+(E2))`,
61
  except that in the case of an array operand, the result is an lvalue if
62
  that operand is an lvalue and an xvalue otherwise.
63
 
@@ -70,20 +73,20 @@ of array types. — *end note*]
70
 
71
  A function call is a postfix expression followed by parentheses
72
  containing a possibly empty, comma-separated list of
73
  *initializer-clause*s which constitute the arguments to the function.
74
 
75
- [*Note 1*: If the postfix expression is a function or member function
76
- name, the appropriate function and the validity of the call are
77
- determined according to the rules in  [[over.match]]. — *end note*]
78
 
79
  The postfix expression shall have function type or function pointer
80
  type. For a call to a non-member function or to a static member
81
- function, the postfix expression shall either be an lvalue that refers
82
  to a function (in which case the function-to-pointer standard conversion
83
- [[conv.func]] is suppressed on the postfix expression), or have function
84
- pointer type.
85
 
86
  If the selected function is non-virtual, or if the *id-expression* in
87
  the class member access expression is a *qualified-id*, that function is
88
  called. Otherwise, its final overrider [[class.virtual]] in the dynamic
89
  type of the object expression is called; such a call is referred to as a
@@ -92,14 +95,13 @@ type of the object expression is called; such a call is referred to as a
92
  [*Note 2*: The dynamic type is the type of the object referred to by
93
  the current value of the object expression. [[class.cdtor]] describes
94
  the behavior of virtual function calls when the object expression refers
95
  to an object under construction or destruction. — *end note*]
96
 
97
- [*Note 3*: If a function or member function name is used, and name
98
- lookup [[basic.lookup]] does not find a declaration of that name, the
99
- program is ill-formed. No function is implicitly declared by such a
100
- call. — *end note*]
101
 
102
  If the *postfix-expression* names a destructor or pseudo-destructor
103
  [[expr.prim.id.dtor]], the type of the function call expression is
104
  `void`; otherwise, the type of the function call expression is the
105
  return type of the statically chosen function (i.e., ignoring the
@@ -108,41 +110,44 @@ different. If the *postfix-expression* names a pseudo-destructor (in
108
  which case the *postfix-expression* is a possibly-parenthesized class
109
  member access), the function call destroys the object of scalar type
110
  denoted by the object expression of the class member access
111
  [[expr.ref]], [[basic.life]].
112
 
113
- Calling a function through an expression whose function type `E` is
114
- different from the function type `F` of the called function’s definition
115
- results in undefined behavior unless the type “pointer to `F`” can be
116
- converted to the type “pointer to `E`” via a function pointer conversion
117
- [[conv.fctptr]].
 
118
 
119
- [*Note 4*: The exception applies when the expression has the type of a
120
- potentially-throwing function, but the called function has a
121
  non-throwing exception specification, and the function types are
122
  otherwise the same. — *end note*]
123
 
124
  When a function is called, each parameter [[dcl.fct]] is initialized
125
- [[dcl.init]], [[class.copy.ctor]] with its corresponding argument. If
126
- the function is an explicit object member function and there is an
127
- implied object argument [[over.call.func]], the list of provided
128
- arguments is preceded by the implied object argument for the purposes of
129
- this correspondence. If there is no corresponding argument, the default
130
- argument for the parameter is used.
 
131
 
132
  [*Example 1*:
133
 
134
  ``` cpp
135
  template<typename ...T> int f(int n = 0, T ...t);
136
  int x = f<int>(); // error: no argument for second function parameter
137
  ```
138
 
139
  — *end example*]
140
 
141
- If the function is an implicit object member function, the `this`
142
- parameter of the function [[expr.prim.this]] is initialized with a
143
- pointer to the object of the call, converted as if by an explicit type
 
144
  conversion [[expr.cast]].
145
 
146
  [*Note 5*: There is no access or ambiguity checking on this conversion;
147
  the access checking and disambiguation are done as part of the (possibly
148
  implicit) class member access operator. See  [[class.member.lookup]],
@@ -153,28 +158,37 @@ class type that is either incomplete or abstract.
153
 
154
  [*Note 6*: This still allows a parameter to be a pointer or reference
155
  to such a type. However, it prevents a passed-by-value parameter to have
156
  an incomplete or abstract class type. — *end note*]
157
 
158
- It is *implementation-defined* whether the lifetime of a parameter ends
159
- when the function in which it is defined returns or at the end of the
160
- enclosing full-expression. The initialization and destruction of each
161
- parameter occurs within the context of the calling function.
 
 
 
162
 
163
- [*Example 2*: The access of the constructor, conversion functions or
164
- destructor is checked at the point of call in the calling function. If a
165
- constructor or destructor for a function parameter throws an exception,
166
- the search for a handler starts in the calling function; in particular,
167
- if the function called has a *function-try-block* [[except.pre]] with a
168
- handler that can handle the exception, this handler is not
169
  considered. — *end example*]
170
 
171
  The *postfix-expression* is sequenced before each *expression* in the
172
  *expression-list* and any default argument. The initialization of a
173
- parameter, including every associated value computation and side effect,
174
- is indeterminately sequenced with respect to that of any other
175
- parameter.
 
 
 
 
 
 
 
176
 
177
  [*Note 7*: All side effects of argument evaluations are sequenced
178
  before the function is entered (see 
179
  [[intro.execution]]). — *end note*]
180
 
@@ -218,17 +232,26 @@ control out of the called function (if any), except in a virtual
218
  function call if the return type of the final overrider is different
219
  from the return type of the statically chosen function, the value
220
  returned from the final overrider is converted to the return type of the
221
  statically chosen function.
222
 
 
 
 
 
 
 
 
 
 
223
  [*Note 9*: A function can change the values of its non-const
224
  parameters, but these changes cannot affect the values of the arguments
225
  except where a parameter is of a reference type [[dcl.ref]]; if the
226
- reference is to a const-qualified type, `const_cast` is required to be
227
- used to cast away the constness in order to modify the argument’s value.
228
- Where a parameter is of `const` reference type a temporary object is
229
- introduced if needed
230
  [[dcl.type]], [[lex.literal]], [[lex.string]], [[dcl.array]], [[class.temporary]].
231
  In addition, it is possible to modify the values of non-constant objects
232
  through pointer parameters. — *end note*]
233
 
234
  A function can be declared to accept fewer arguments (by declaring
@@ -254,15 +277,16 @@ The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
254
  function-to-pointer [[conv.func]] standard conversions are performed on
255
  the argument expression. An argument that has type cv `std::nullptr_t`
256
  is converted to type `void*` [[conv.ptr]]. After these conversions, if
257
  the argument does not have arithmetic, enumeration, pointer,
258
  pointer-to-member, or class type, the program is ill-formed. Passing a
259
- potentially-evaluated argument of a scoped enumeration type or of a
260
- class type [[class]] having an eligible non-trivial copy constructor, an
261
- eligible non-trivial move constructor, or a non-trivial destructor
262
- [[special]], with no corresponding parameter, is conditionally-supported
263
- with *implementation-defined* semantics. If the argument has integral or
 
264
  enumeration type that is subject to the integral promotions
265
  [[conv.prom]], or a floating-point type that is subject to the
266
  floating-point promotion [[conv.fpprom]], the value of the argument is
267
  converted to the promoted type before the call. These promotions are
268
  referred to as the *default argument promotions*.
@@ -270,11 +294,13 @@ referred to as the *default argument promotions*.
270
  Recursive calls are permitted, except to the `main` function
271
  [[basic.start.main]].
272
 
273
  A function call is an lvalue if the result type is an lvalue reference
274
  type or an rvalue reference to function type, an xvalue if the result
275
- type is an rvalue reference to object type, and a prvalue otherwise.
 
 
276
 
277
  #### Explicit type conversion (functional notation) <a id="expr.type.conv">[[expr.type.conv]]</a>
278
 
279
  A *simple-type-specifier* [[dcl.type.simple]] or *typename-specifier*
280
  [[temp.res]] followed by a parenthesized optional *expression-list* or
@@ -283,11 +309,28 @@ specified type given the initializer. If the type is a placeholder for a
283
  deduced class type, it is replaced by the return type of the function
284
  selected by overload resolution for class template deduction
285
  [[over.match.class.deduct]] for the remainder of this subclause.
286
  Otherwise, if the type contains a placeholder type, it is replaced by
287
  the type determined by placeholder type deduction
288
- [[dcl.type.auto.deduct]].
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  [*Example 1*:
291
 
292
  ``` cpp
293
  struct A {};
@@ -301,44 +344,41 @@ void h() {
301
  }
302
  ```
303
 
304
  — *end example*]
305
 
306
- If the initializer is a parenthesized single expression, the type
307
- conversion expression is equivalent to the corresponding cast expression
308
- [[expr.cast]]. Otherwise, if the type is cv `void` and the initializer
309
- is `()` or `{}` (after pack expansion, if any), the expression is a
310
- prvalue of type `void` that performs no initialization. Otherwise, the
311
- expression is a prvalue of the specified type whose result object is
312
- direct-initialized [[dcl.init]] with the initializer. If the initializer
313
- is a parenthesized optional *expression-list*, the specified type shall
314
- not be an array type.
315
-
316
  #### Class member access <a id="expr.ref">[[expr.ref]]</a>
317
 
318
  A postfix expression followed by a dot `.` or an arrow `->`, optionally
319
  followed by the keyword `template`, and then followed by an
320
- *id-expression*, is a postfix expression. The postfix expression before
321
- the dot or arrow is evaluated;[^12]
322
 
323
- the result of that evaluation, together with the *id-expression*,
324
- determines the result of the entire postfix expression.
 
 
 
325
 
326
- [*Note 1*: If the keyword `template` is used, the following unqualified
327
- name is considered to refer to a template [[temp.names]]. If a
328
- *simple-template-id* results and is followed by a `::`, the
329
- *id-expression* is a *qualified-id*. — *end note*]
 
 
 
 
330
 
331
- For the first option (dot) the first expression shall be a glvalue. For
332
- the second option (arrow) the first expression shall be a prvalue having
333
- pointer type. The expression `E1->E2` is converted to the equivalent
334
- form `(*(E1)).E2`; the remainder of [[expr.ref]] will address only the
335
- first option (dot).[^13]
336
 
337
- Abbreviating *postfix-expression*`.`*id-expression* as `E1.E2`, `E1` is
338
- called the *object expression*. If the object expression is of scalar
339
- type, `E2` shall name the pseudo-destructor of that same type (ignoring
 
 
 
 
 
340
  cv-qualifications) and `E1.E2` is a prvalue of type “function of ()
341
  returning `void`”.
342
 
343
  [*Note 2*: This value can only be used for a notional function call
344
  [[expr.prim.id.dtor]]. — *end note*]
@@ -351,68 +391,105 @@ definition of that class.
351
  when the class is complete [[class.member.lookup]]. — *end note*]
352
 
353
  [*Note 4*: [[basic.lookup.qual]] describes how names are looked up
354
  after the `.` and `->` operators. — *end note*]
355
 
356
- If `E2` is a bit-field, `E1.E2` is a bit-field. The type and value
357
- category of `E1.E2` are determined as follows. In the remainder of 
358
- [[expr.ref]], *cq* represents either `const` or the absence of `const`
359
- and *vq* represents either `volatile` or the absence of `volatile`. *cv*
360
- represents an arbitrary set of cv-qualifiers, as defined in 
361
- [[basic.type.qualifier]].
362
 
363
- If `E2` is declared to have type “reference to `T`”, then `E1.E2` is an
364
- lvalue of type `T`. If `E2` is a static data member, `E1.E2` designates
365
- the object or function to which the reference is bound, otherwise
366
- `E1.E2` designates the object or function to which the corresponding
367
- reference member of `E1` is bound. Otherwise, one of the following rules
368
- applies.
369
 
370
- - If `E2` is a static data member and the type of `E2` is `T`, then
371
- `E1.E2` is an lvalue; the expression designates the named member of
372
- the class. The type of `E1.E2` is `T`.
373
- - If `E2` is a non-static data member and the type of `E1` is “*cq1 vq1*
374
- `X`”, and the type of `E2` is “*cq2 vq2* `T`”, the expression
375
- designates the corresponding member subobject of the object designated
376
- by the first expression. If `E1` is an lvalue, then `E1.E2` is an
377
- lvalue; otherwise `E1.E2` is an xvalue. Let the notation *vq12* stand
378
- for the “union” of *vq1* and *vq2*; that is, if *vq1* or *vq2* is
379
- `volatile`, then *vq12* is `volatile`. Similarly, let the notation
380
- *cq12* stand for the “union” of *cq1* and *cq2*; that is, if *cq1* or
381
- *cq2* is `const`, then *cq12* is `const`. If `E2` is declared to be a
382
- `mutable` member, then the type of `E1.E2` is “*vq12* `T`”. If `E2` is
383
- not declared to be a `mutable` member, then the type of `E1.E2` is
384
- “*cq12* *vq12* `T`”.
385
- - If `E2` is an overload set, function overload resolution
386
- [[over.match]] is used to select the function to which `E2` refers.
387
- The type of `E1.E2` is the type of `E2` and `E1.E2` refers to the
388
- function referred to by `E2`.
 
 
 
 
 
 
 
 
 
389
  - If `E2` refers to a static member function, `E1.E2` is an lvalue.
390
  - Otherwise (when `E2` refers to a non-static member function),
391
- `E1.E2` is a prvalue. The expression can be used only as the
392
- left-hand operand of a member function call [[class.mfct]].
393
- \[*Note 5*: Any redundant set of parentheses surrounding the
394
- expression is ignored [[expr.prim.paren]]. *end note*]
395
- - If `E2` is a nested type, the expression `E1.E2` is ill-formed.
396
- - If `E2` is a member enumerator and the type of `E2` is `T`, the
397
- expression `E1.E2` is a prvalue of type `T` whose value is the value
398
- of the enumerator.
399
-
400
- If `E2` is a non-static member, the program is ill-formed if the class
401
- of which `E2` is directly a member is an ambiguous base
402
- [[class.member.lookup]] of the naming class [[class.access.base]] of
403
- `E2`.
404
-
405
- [*Note 6*: The program is also ill-formed if the naming class is an
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  ambiguous base of the class type of the object expression; see 
407
  [[class.access.base]]. — *end note*]
408
 
409
- If `E2` is a non-static member and the result of `E1` is an object whose
410
- type is not similar [[conv.qual]] to the type of `E1`, the behavior is
411
- undefined.
412
 
413
- [*Example 1*:
414
 
415
  ``` cpp
416
  struct A { int i; };
417
  struct B { int j; };
418
  struct D : A, B {};
@@ -425,33 +502,32 @@ void f() {
425
 
426
  — *end example*]
427
 
428
  #### Increment and decrement <a id="expr.post.incr">[[expr.post.incr]]</a>
429
 
430
- The value of a postfix `++` expression is the value of its operand.
 
431
 
432
  [*Note 1*: The value obtained is a copy of the original
433
  value. — *end note*]
434
 
435
  The operand shall be a modifiable lvalue. The type of the operand shall
436
  be an arithmetic type other than cv `bool`, or a pointer to a complete
437
  object type. An operand with volatile-qualified type is deprecated; see 
438
  [[depr.volatile.type]]. The value of the operand object is modified
439
- [[defns.access]] by adding `1` to it. The value computation of the `++`
440
- expression is sequenced before the modification of the operand object.
441
- With respect to an indeterminately-sequenced function call, the
442
- operation of postfix `++` is a single evaluation.
 
443
 
444
  [*Note 2*: Therefore, a function call cannot intervene between the
445
  lvalue-to-rvalue conversion and the side effect associated with any
446
  single postfix `++` operator. — *end note*]
447
 
448
  The result is a prvalue. The type of the result is the cv-unqualified
449
- version of the type of the operand. If the operand is a bit-field that
450
- cannot represent the incremented value, the resulting value of the
451
- bit-field is *implementation-defined*. See also  [[expr.add]] and 
452
- [[expr.ass]].
453
 
454
  The operand of postfix `--` is decremented analogously to the postfix
455
  `++` operator.
456
 
457
  [*Note 3*: For prefix increment and decrement, see 
@@ -479,11 +555,11 @@ If `T` is “pointer to *cv1* `B`” and `v` has type “pointer to *cv2* `D`”
479
  such that `B` is a base class of `D`, the result is a pointer to the
480
  unique `B` subobject of the `D` object pointed to by `v`, or a null
481
  pointer value if `v` is a null pointer value. Similarly, if `T` is
482
  “reference to *cv1* `B`” and `v` has type *cv2* `D` such that `B` is a
483
  base class of `D`, the result is the unique `B` subobject of the `D`
484
- object referred to by `v`.[^14]
485
 
486
  In both the pointer and reference cases, the program is ill-formed if
487
  `B` is an inaccessible or ambiguous base class of `D`.
488
 
489
  [*Example 1*:
@@ -501,10 +577,18 @@ void foo(D* dp) {
501
  Otherwise, `v` shall be a pointer to or a glvalue of a polymorphic type
502
  [[class.virtual]].
503
 
504
  If `v` is a null pointer value, the result is a null pointer value.
505
 
 
 
 
 
 
 
 
 
506
  If `T` is “pointer to cv `void`”, then the result is a pointer to the
507
  most derived object pointed to by `v`. Otherwise, a runtime check is
508
  applied to see if the object pointed or referred to by `v` can be
509
  converted to the type pointed or referred to by `T`.
510
 
@@ -512,11 +596,11 @@ Let `C` be the class type to which `T` points or refers. The runtime
512
  check logically executes as follows:
513
 
514
  - If, in the most derived object pointed (referred) to by `v`, `v`
515
  points (refers) to a public base class subobject of a `C` object, and
516
  if only one object of type `C` is derived from the subobject pointed
517
- (referred) to by `v` the result points (refers) to that `C` object.
518
  - Otherwise, if `v` points (refers) to a public base class subobject of
519
  the most derived object, and the type of the most derived object has a
520
  base class, of type `C`, that is unambiguous and public, the result
521
  points (refers) to the `C` subobject of the most derived object.
522
  - Otherwise, the runtime check *fails*.
@@ -562,31 +646,35 @@ destruction. — *end note*]
562
 
563
  #### Type identification <a id="expr.typeid">[[expr.typeid]]</a>
564
 
565
  The result of a `typeid` expression is an lvalue of static type `const`
566
  `std::type_info` [[type.info]] and dynamic type `const` `std::type_info`
567
- or `const` *name* where *name* is an *implementation-defined* class
568
  publicly derived from `std::type_info` which preserves the behavior
569
- described in  [[type.info]].[^15]
570
 
571
  The lifetime of the object referred to by the lvalue extends to the end
572
  of the program. Whether or not the destructor is called for the
573
  `std::type_info` object at the end of the program is unspecified.
574
 
575
  If the type of the *expression* or *type-id* operand is a (possibly
576
  cv-qualified) class type or a reference to (possibly cv-qualified) class
577
  type, that class shall be completely defined.
578
 
 
 
 
 
 
 
 
 
 
579
  When `typeid` is applied to a glvalue whose type is a polymorphic class
580
  type [[class.virtual]], the result refers to a `std::type_info` object
581
  representing the type of the most derived object [[intro.object]] (that
582
- is, the dynamic type) to which the glvalue refers. If the glvalue is
583
- obtained by applying the unary `*` operator to a pointer[^16]
584
-
585
- and the pointer is a null pointer value [[basic.compound]], the `typeid`
586
- expression throws an exception [[except.throw]] of a type that would
587
- match a handler of type `std::bad_typeid` exception [[bad.typeid]].
588
 
589
  When `typeid` is applied to an expression other than a glvalue of a
590
  polymorphic class type, the result refers to a `std::type_info` object
591
  representing the static type of the expression. Lvalue-to-rvalue
592
  [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
@@ -599,11 +687,11 @@ When `typeid` is applied to a *type-id*, the result refers to a
599
  `std::type_info` object representing the type of the *type-id*. If the
600
  type of the *type-id* is a reference to a possibly cv-qualified type,
601
  the result of the `typeid` expression refers to a `std::type_info`
602
  object representing the cv-unqualified referenced type.
603
 
604
- [*Note 1*: The *type-id* cannot denote a function type with a
605
  *cv-qualifier-seq* or a *ref-qualifier* [[dcl.fct]]. — *end note*]
606
 
607
  If the type of the expression or *type-id* is a cv-qualified type, the
608
  result of the `typeid` expression refers to a `std::type_info` object
609
  representing the cv-unqualified type.
@@ -626,24 +714,23 @@ typeid(D) == typeid(const D&); // yields true
626
  The type `std::type_info` [[type.info]] is not predefined; if a standard
627
  library declaration [[typeinfo.syn]], [[std.modules]] of
628
  `std::type_info` does not precede [[basic.lookup.general]] a `typeid`
629
  expression, the program is ill-formed.
630
 
631
- [*Note 2*: Subclause [[class.cdtor]] describes the behavior of `typeid`
632
  applied to an object under construction or destruction. — *end note*]
633
 
634
  #### Static cast <a id="expr.static.cast">[[expr.static.cast]]</a>
635
 
636
  The result of the expression `static_cast<T>(v)` is the result of
637
  converting the expression `v` to type `T`. If `T` is an lvalue reference
638
  type or an rvalue reference to function type, the result is an lvalue;
639
  if `T` is an rvalue reference to object type, the result is an xvalue;
640
- otherwise, the result is a prvalue. The `static_cast` operator shall not
641
- cast away constness [[expr.const.cast]].
642
 
643
  An lvalue of type “*cv1* `B`”, where `B` is a class type, can be cast to
644
- type “reference to *cv2* `D`”, where `D` is a class derived
645
  [[class.derived]] from `B`, if *cv2* is the same cv-qualification as, or
646
  greater cv-qualification than, *cv1*. If `B` is a virtual base class of
647
  `D` or a base class of a virtual base class of `D`, or if no valid
648
  standard conversion from “pointer to `D`” to “pointer to `B`” exists
649
  [[conv.ptr]], the program is ill-formed. An xvalue of type “*cv1* `B`”
@@ -674,14 +761,25 @@ class subobject thereof; otherwise, the lvalue-to-rvalue conversion
674
  used as the operand of the `static_cast` for the remainder of this
675
  subclause. If `T2` is an inaccessible [[class.access]] or ambiguous
676
  [[class.member.lookup]] base class of `T1`, a program that necessitates
677
  such a cast is ill-formed.
678
 
679
- An expression E can be explicitly converted to a type `T` if there is an
680
- implicit conversion sequence [[over.best.ics]] from E to `T`, if
681
- overload resolution for a direct-initialization [[dcl.init]] of an
682
- object or reference of type `T` from E would find at least one viable
 
 
 
 
 
 
 
 
 
 
 
683
  function [[over.match.viable]], or if `T` is an aggregate type
684
  [[dcl.init.aggr]] having a first element `x` and there is an implicit
685
  conversion sequence from E to the type of `x`. If `T` is a reference
686
  type, the effect is the same as performing the declaration and
687
  initialization
@@ -692,59 +790,23 @@ T t(E);
692
 
693
  for some invented temporary variable `t` [[dcl.init]] and then using the
694
  temporary variable as the result of the conversion. Otherwise, the
695
  result object is direct-initialized from E.
696
 
697
- [*Note 1*: The conversion is ill-formed when attempting to convert an
698
  expression of class type to an inaccessible or ambiguous base
699
  class. — *end note*]
700
 
701
- [*Note 2*: If `T` is “array of unknown bound of `U`”, this
702
  direct-initialization defines the type of the expression as
703
  `U[1]`. — *end note*]
704
 
705
- Otherwise, the `static_cast` shall perform one of the conversions listed
706
- below. No other conversion shall be performed explicitly using a
707
- `static_cast`.
708
-
709
- Any expression can be explicitly converted to type cv `void`, in which
710
- case the operand is a discarded-value expression [[expr.prop]].
711
-
712
- [*Note 3*: Such a `static_cast` has no result as it is a prvalue of
713
- type `void`; see  [[basic.lval]]. — *end note*]
714
-
715
- [*Note 4*: However, if the value is in a temporary object
716
- [[class.temporary]], the destructor for that object is not executed
717
- until the usual time, and the value of the object is preserved for the
718
- purpose of executing the destructor. — *end note*]
719
-
720
- The inverse of any standard conversion sequence [[conv]] not containing
721
- an lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]],
722
- function-to-pointer [[conv.func]], null pointer [[conv.ptr]], null
723
- member pointer [[conv.mem]], boolean [[conv.bool]], or function pointer
724
- [[conv.fctptr]] conversion, can be performed explicitly using
725
- `static_cast`. A program is ill-formed if it uses `static_cast` to
726
- perform the inverse of an ill-formed standard conversion sequence.
727
-
728
- [*Example 2*:
729
-
730
- ``` cpp
731
- struct B { };
732
- struct D : private B { };
733
- void f() {
734
- static_cast<D*>((B*)0); // error: B is a private base of D
735
- static_cast<int B::*>((int D::*)0); // error: B is a private base of D
736
- }
737
- ```
738
-
739
- — *end example*]
740
-
741
- The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
742
- function-to-pointer [[conv.func]] conversions are applied to the
743
- operand. Such a `static_cast` is subject to the restriction that the
744
- explicit conversion does not cast away constness [[expr.const.cast]],
745
- and the following additional rules for specific cases:
746
 
747
  A value of a scoped enumeration type [[dcl.enum]] can be explicitly
748
  converted to an integral type; the result is the same as that of
749
  converting to the enumeration’s underlying type and then to the
750
  destination type. A value of a scoped enumeration type can also be
@@ -797,14 +859,13 @@ pointer-to-member-function types) are never cv-qualified
797
 
798
  If no valid standard conversion from “pointer to member of `B` of type
799
  `T`” to “pointer to member of `D` of type `T`” exists [[conv.mem]], the
800
  program is ill-formed. The null member pointer value [[conv.mem]] is
801
  converted to the null member pointer value of the destination type. If
802
- class `B` contains the original member, or is a base or derived class of
803
- the class containing the original member, the resulting pointer to
804
- member points to the original member. Otherwise, the behavior is
805
- undefined.
806
 
807
  [*Note 6*: Although class `B` need not contain the original member, the
808
  dynamic type of the object with which indirection through the pointer to
809
  member is performed must contain the original member; see 
810
  [[expr.mptr.oper]]. — *end note*]
@@ -812,17 +873,18 @@ member is performed must contain the original member; see 
812
  A prvalue of type “pointer to *cv1* `void`” can be converted to a
813
  prvalue of type “pointer to *cv2* `T`”, where `T` is an object type and
814
  *cv2* is the same cv-qualification as, or greater cv-qualification than,
815
  *cv1*. If the original pointer value represents the address `A` of a
816
  byte in memory and `A` does not satisfy the alignment requirement of
817
- `T`, then the resulting pointer value is unspecified. Otherwise, if the
818
- original pointer value points to an object *a*, and there is an object
819
- *b* of type similar to `T` that is pointer-interconvertible
820
- [[basic.compound]] with *a*, the result is a pointer to *b*. Otherwise,
821
- the pointer value is unchanged by the conversion.
 
822
 
823
- [*Example 3*:
824
 
825
  ``` cpp
826
  T* p1 = new T;
827
  const T* p2 = static_cast<const T*>(static_cast<void*>(p1));
828
  bool b = p1 == p2; // b will have the value true.
@@ -867,12 +929,12 @@ the conversion has the same meaning and validity as a conversion of
867
  any type to the type `std::nullptr_t`. — *end note*]
868
 
869
  A value of integral type or enumeration type can be explicitly converted
870
  to a pointer. A pointer converted to an integer of sufficient size (if
871
  any such exists on the implementation) and back to the same pointer type
872
- will have its original value; mappings between pointers and integers are
873
- otherwise *implementation-defined*.
874
 
875
  A function pointer can be explicitly converted to a function pointer of
876
  a different type.
877
 
878
  [*Note 4*: The effect of calling a function through a pointer to a
@@ -882,21 +944,18 @@ definition of the function is undefined [[expr.call]]. — *end note*]
882
  Except that converting a prvalue of type “pointer to `T1`” to the type
883
  “pointer to `T2`” (where `T1` and `T2` are function types) and back to
884
  its original type yields the original pointer value, the result of such
885
  a pointer conversion is unspecified.
886
 
887
- [*Note 5*: See also  [[conv.ptr]] for more details of pointer
888
- conversions. — *end note*]
889
-
890
  An object pointer can be explicitly converted to an object pointer of a
891
- different type.[^17]
892
 
893
  When a prvalue `v` of object pointer type is converted to the object
894
  pointer type “pointer to cv `T`”, the result is
895
  `static_cast<cv T*>(static_cast<cv~void*>(v))`.
896
 
897
- [*Note 6*: Converting a pointer of type “pointer to `T1`” that points
898
  to an object of type `T1` to the type “pointer to `T2`” (where `T2` is
899
  an object type and the alignment requirements of `T2` are no stricter
900
  than those of `T1`) and back to its original type yields the original
901
  pointer value. — *end note*]
902
 
@@ -908,19 +967,19 @@ other type and back, possibly with different cv-qualification, shall
908
  yield the original pointer value.
909
 
910
  The null pointer value [[basic.compound]] is converted to the null
911
  pointer value of the destination type.
912
 
913
- [*Note 7*: A null pointer constant of type `std::nullptr_t` cannot be
914
  converted to a pointer type, and a null pointer constant of integral
915
  type is not necessarily converted to a null pointer
916
  value. — *end note*]
917
 
918
  A prvalue of type “pointer to member of `X` of type `T1`” can be
919
  explicitly converted to a prvalue of a different type “pointer to member
920
  of `Y` of type `T2`” if `T1` and `T2` are both function types or both
921
- object types.[^18]
922
 
923
  The null member pointer value [[conv.mem]] is converted to the null
924
  member pointer value of the destination type. The result of this
925
  conversion is unspecified, except in the following cases:
926
 
@@ -931,79 +990,83 @@ conversion is unspecified, except in the following cases:
931
  `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
932
  the alignment requirements of `T2` are no stricter than those of `T1`)
933
  and back to its original type yields the original pointer-to-member
934
  value.
935
 
936
- A glvalue of type `T1`, designating an object *x*, can be cast to the
937
- type “reference to `T2`” if an expression of type “pointer to `T1`” can
938
- be explicitly converted to the type “pointer to `T2`” using a
939
- `reinterpret_cast`. The result is that of `*reinterpret_cast<T2 *>(p)`
940
- where `p` is a pointer to *x* of type “pointer to `T1`”. No temporary is
941
- created, no copy is made, and no constructors [[class.ctor]] or
942
- conversion functions [[class.conv]] are called.[^19]
 
 
 
 
 
 
 
943
 
944
  #### Const cast <a id="expr.const.cast">[[expr.const.cast]]</a>
945
 
946
  The result of the expression `const_cast<T>(v)` is of type `T`. If `T`
947
  is an lvalue reference to object type, the result is an lvalue; if `T`
948
  is an rvalue reference to object type, the result is an xvalue;
949
  otherwise, the result is a prvalue and the lvalue-to-rvalue
950
  [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
951
  [[conv.func]] standard conversions are performed on the expression `v`.
952
- Conversions that can be performed explicitly using `const_cast` are
953
- listed below. No other conversion shall be performed explicitly using
954
- `const_cast`.
 
955
 
956
  [*Note 1*: Subject to the restrictions in this subclause, an expression
957
  can be cast to its own type using a `const_cast`
958
  operator. — *end note*]
959
 
960
- For two similar types `T1` and `T2` [[conv.qual]], a prvalue of type
961
- `T1` may be explicitly converted to the type `T2` using a `const_cast`
962
- if, considering the qualification-decompositions of both types, each P¹ᵢ
963
- is the same as P²for all i. The result of a `const_cast` refers to the
964
- original entity.
965
-
966
- [*Example 1*:
967
-
968
- ``` cpp
969
- typedef int *A[3]; // array of 3 pointer to int
970
- typedef const int *const CA[3]; // array of 3 const pointer to const int
971
-
972
- CA &&r = A{}; // OK, reference binds to temporary array object
973
- // after qualification conversion to type CA
974
- A &&r1 = const_cast<A>(CA{}); // error: temporary array decayed to pointer
975
- A &&r2 = const_cast<A&&>(CA{}); // OK
976
- ```
977
-
978
- — *end example*]
979
 
980
  For two object types `T1` and `T2`, if a pointer to `T1` can be
981
  explicitly converted to the type “pointer to `T2`” using a `const_cast`,
982
  then the following conversions can also be made:
983
 
984
  - an lvalue of type `T1` can be explicitly converted to an lvalue of
985
  type `T2` using the cast `const_cast<T2&>`;
986
  - a glvalue of type `T1` can be explicitly converted to an xvalue of
987
  type `T2` using the cast `const_cast<T2&&>`; and
988
- - if `T1` is a class type, a prvalue of type `T1` can be explicitly
989
- converted to an xvalue of type `T2` using the cast `const_cast<T2&&>`.
 
 
990
 
991
- The result of a reference `const_cast` refers to the original object if
992
- the operand is a glvalue and to the result of applying the temporary
993
- materialization conversion [[conv.rval]] otherwise.
994
 
995
- A null pointer value [[basic.compound]] is converted to the null pointer
996
- value of the destination type. The null member pointer value
997
- [[conv.mem]] is converted to the null member pointer value of the
998
- destination type.
 
 
 
 
 
 
999
 
1000
  [*Note 2*:
1001
 
1002
  Depending on the type of the object, a write operation through the
1003
  pointer, lvalue or pointer to data member resulting from a `const_cast`
1004
- that casts away a const-qualifier[^20]
1005
 
1006
  can produce undefined behavior [[dcl.type.cv]].
1007
 
1008
  — *end note*]
1009
 
@@ -1049,10 +1112,11 @@ unary-expression:
1049
  sizeof '...' '(' identifier ')'
1050
  alignof '(' type-id ')'
1051
  noexcept-expression
1052
  new-expression
1053
  delete-expression
 
1054
  ```
1055
 
1056
  ``` bnf
1057
  %% Ed. note: character protrusion would misalign operators.
1058
 
@@ -1062,33 +1126,42 @@ unary-operator: one of
1062
 
1063
  #### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
1064
 
1065
  The unary `*` operator performs *indirection*. Its operand shall be a
1066
  prvalue of type “pointer to `T`”, where `T` is an object or function
1067
- type. The operator yields an lvalue of type `T` denoting the object or
1068
- function to which the operand points.
 
 
1069
 
1070
- [*Note 1*: Indirection through a pointer to an incomplete type (other
 
 
 
1071
  than cv `void`) is valid. The lvalue thus obtained can be used in
1072
  limited ways (to initialize a reference, for example); this lvalue must
1073
  not be converted to a prvalue, see  [[conv.lval]]. — *end note*]
1074
 
1075
  Each of the following unary operators yields a prvalue.
1076
 
1077
  The operand of the unary `&` operator shall be an lvalue of some type
1078
- `T`. The result is a prvalue.
1079
 
1080
- - If the operand is a *qualified-id* naming a non-static or variant
1081
- member `m` of some class `C`, other than an explicit object member
1082
- function, the result has type “pointer to member of class `C` of type
1083
- `T`” and designates `C::m`.
 
 
 
 
1084
  - Otherwise, the result has type “pointer to `T`” and points to the
1085
  designated object [[intro.memory]] or function [[basic.compound]]. If
1086
- the operand names an explicit object member function [[dcl.fct]], the
1087
- operand shall be a *qualified-id*. \[*Note 2*: In particular, taking
1088
- the address of a variable of type “cv `T`” yields a pointer of type
1089
- “pointer to cv `T`”. — *end note*]
1090
 
1091
  [*Example 1*:
1092
 
1093
  ``` cpp
1094
  struct A { int i; };
@@ -1100,18 +1173,19 @@ int* p2 = p1 + 1; // defined behavior
1100
  bool b = p2 > p1; // defined behavior, with value true
1101
  ```
1102
 
1103
  — *end example*]
1104
 
1105
- [*Note 3*: A pointer to member formed from a `mutable` non-static data
1106
  member [[dcl.stc]] does not reflect the `mutable` specifier associated
1107
  with the non-static data member. — *end note*]
1108
 
1109
  A pointer to member is only formed when an explicit `&` is used and its
1110
- operand is a *qualified-id* not enclosed in parentheses.
 
1111
 
1112
- [*Note 4*: That is, the expression `&(qualified-id)`, where the
1113
  *qualified-id* is enclosed in parentheses, does not form an expression
1114
  of type “pointer to member”. Neither does `qualified-id`, because there
1115
  is no implicit conversion from a *qualified-id* for a non-static member
1116
  function to the type “pointer to member function” as there is from an
1117
  lvalue of function type to the type “pointer to function” [[conv.func]].
@@ -1121,99 +1195,96 @@ the *unqualified-id*’s class. — *end note*]
1121
  If `&` is applied to an lvalue of incomplete class type and the complete
1122
  type declares `operator&()`, it is unspecified whether the operator has
1123
  the built-in meaning or the operator function is called. The operand of
1124
  `&` shall not be a bit-field.
1125
 
1126
- [*Note 5*: The address of an overload set [[over]] can be taken only in
1127
  a context that uniquely determines which function is referred to (see 
1128
  [[over.over]]). Since the context can affect whether the operand is a
1129
  static or non-static member function, the context can also affect
1130
  whether the expression has type “pointer to function” or “pointer to
1131
  member function”. — *end note*]
1132
 
1133
- The operand of the unary `+` operator shall have arithmetic, unscoped
1134
- enumeration, or pointer type and the result is the value of the
1135
  argument. Integral promotion is performed on integral or enumeration
1136
  operands. The type of the result is the type of the promoted operand.
1137
 
1138
- The operand of the unary `-` operator shall have arithmetic or unscoped
1139
- enumeration type and the result is the negative of its operand. Integral
1140
- promotion is performed on integral or enumeration operands. The negative
1141
- of an unsigned quantity is computed by subtracting its value from 2ⁿ,
1142
- where n is the number of bits in the promoted operand. The type of the
1143
- result is the type of the promoted operand.
 
1144
 
1145
- [*Note 6*: The result is the two’s complement of the operand (where
1146
  operand and result are considered as unsigned). — *end note*]
1147
 
1148
  The operand of the logical negation operator `!` is contextually
1149
  converted to `bool` [[conv]]; its value is `true` if the converted
1150
  operand is `false` and `false` otherwise. The type of the result is
1151
  `bool`.
1152
 
1153
- The operand of the `~` operator shall have integral or unscoped
1154
- enumeration type. Integral promotions are performed. The type of the
1155
- result is the type of the promoted operand. Given the coefficients `xᵢ`
1156
- of the base-2 representation [[basic.fundamental]] of the promoted
1157
- operand `x`, the coefficient `rᵢ` of the base-2 representation of the
1158
- result `r` is 1 if `xᵢ` is 0, and 0 otherwise.
1159
 
1160
- [*Note 7*: The result is the ones’ complement of the operand (where
1161
  operand and result are considered as unsigned). — *end note*]
1162
 
1163
  There is an ambiguity in the grammar when `~` is followed by a
1164
- *type-name* or *decltype-specifier*. The ambiguity is resolved by
1165
  treating `~` as the operator rather than as the start of an
1166
  *unqualified-id* naming a destructor.
1167
 
1168
- [*Note 8*: Because the grammar does not permit an operator to follow
1169
  the `.`, `->`, or `::` tokens, a `~` followed by a *type-name* or
1170
- *decltype-specifier* in a member access expression or *qualified-id* is
1171
- unambiguously parsed as a destructor name. — *end note*]
 
1172
 
1173
  #### Increment and decrement <a id="expr.pre.incr">[[expr.pre.incr]]</a>
1174
 
1175
- The operand of prefix `++` is modified [[defns.access]] by adding `1`.
1176
- The operand shall be a modifiable lvalue. The type of the operand shall
1177
- be an arithmetic type other than cv `bool`, or a pointer to a
1178
- completely-defined object type. An operand with volatile-qualified type
1179
- is deprecated; see  [[depr.volatile.type]]. The result is the updated
1180
- operand; it is an lvalue, and it is a bit-field if the operand is a
1181
- bit-field. The expression `++x` is equivalent to `x+=1`.
1182
 
1183
- [*Note 1*: See the discussions of addition [[expr.add]] and assignment
1184
- operators [[expr.ass]] for information on conversions. — *end note*]
1185
-
1186
- The operand of prefix `--` is modified [[defns.access]] by subtracting
1187
- `1`. The requirements on the operand of prefix `--` and the properties
1188
- of its result are otherwise the same as those of prefix `++`.
1189
-
1190
- [*Note 2*: For postfix increment and decrement, see 
1191
  [[expr.post.incr]]. — *end note*]
1192
 
1193
  #### Await <a id="expr.await">[[expr.await]]</a>
1194
 
1195
  The `co_await` expression is used to suspend evaluation of a coroutine
1196
  [[dcl.fct.def.coroutine]] while awaiting completion of the computation
1197
- represented by the operand expression.
 
1198
 
1199
  ``` bnf
1200
  await-expression:
1201
- 'co_await' cast-expression
1202
  ```
1203
 
1204
- An *await-expression* shall appear only in a potentially-evaluated
1205
- expression within the *compound-statement* of a *function-body* outside
1206
- of a *handler* [[except.pre]]. In a *declaration-statement* or in the
 
1207
  *simple-declaration* (if any) of an *init-statement*, an
1208
  *await-expression* shall appear only in an *initializer* of that
1209
  *declaration-statement* or *simple-declaration*. An *await-expression*
1210
  shall not appear in a default argument [[dcl.fct.default]]. An
1211
  *await-expression* shall not appear in the initializer of a block
1212
- variable with static or thread storage duration. A context within a
1213
- function where an *await-expression* can appear is called a *suspension
1214
- context* of the function.
 
 
1215
 
1216
  Evaluation of an *await-expression* involves the following auxiliary
1217
  types, expressions, and objects:
1218
 
1219
  - *p* is an lvalue naming the promise object [[dcl.fct.def.coroutine]]
@@ -1333,11 +1404,11 @@ to any other fundamental type [[basic.fundamental]] is
1333
 
1334
  [*Note 1*:
1335
 
1336
  In particular, the values of `sizeof(bool)`, `sizeof(char16_t)`,
1337
  `sizeof(char32_t)`, and `sizeof(wchar_t)` are
1338
- implementation-defined.[^21]
1339
 
1340
  — *end note*]
1341
 
1342
  [*Note 2*: See  [[intro.memory]] for the definition of byte and 
1343
  [[term.object.representation]] for the definition of object
@@ -1346,83 +1417,84 @@ representation. — *end note*]
1346
  When applied to a reference type, the result is the size of the
1347
  referenced type. When applied to a class, the result is the number of
1348
  bytes in an object of that class including any padding required for
1349
  placing objects of that type in an array. The result of applying
1350
  `sizeof` to a potentially-overlapping subobject is the size of the type,
1351
- not the size of the subobject.[^22]
1352
 
1353
  When applied to an array, the result is the total number of bytes in the
1354
  array. This implies that the size of an array of n elements is n times
1355
  the size of an element.
1356
 
1357
  The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
1358
  function-to-pointer [[conv.func]] standard conversions are not applied
1359
  to the operand of `sizeof`. If the operand is a prvalue, the temporary
1360
  materialization conversion [[conv.rval]] is applied.
1361
 
1362
- The identifier in a `sizeof...` expression shall name a pack. The
1363
  `sizeof...` operator yields the number of elements in the pack
1364
  [[temp.variadic]]. A `sizeof...` expression is a pack expansion
1365
  [[temp.variadic]].
1366
 
1367
  [*Example 1*:
1368
 
1369
  ``` cpp
1370
  template<class... Types>
1371
  struct count {
1372
- static const std::size_t value = sizeof...(Types);
1373
  };
1374
  ```
1375
 
1376
  — *end example*]
1377
 
1378
  The result of `sizeof` and `sizeof...` is a prvalue of type
1379
  `std::size_t`.
1380
 
1381
  [*Note 3*: A `sizeof` expression is an integral constant expression
1382
- [[expr.const]]. The type `std::size_t` is defined in the standard header
1383
- `<cstddef>` [[cstddef.syn]], [[support.types.layout]]. — *end note*]
 
1384
 
1385
  #### Alignof <a id="expr.alignof">[[expr.alignof]]</a>
1386
 
1387
  An `alignof` expression yields the alignment requirement of its operand
1388
  type. The operand shall be a *type-id* representing a complete object
1389
  type, or an array thereof, or a reference to one of those types.
1390
 
1391
  The result is a prvalue of type `std::size_t`.
1392
 
1393
  [*Note 1*: An `alignof` expression is an integral constant expression
1394
- [[expr.const]]. The type `std::size_t` is defined in the standard header
1395
- `<cstddef>` [[cstddef.syn]], [[support.types.layout]]. — *end note*]
 
1396
 
1397
  When `alignof` is applied to a reference type, the result is the
1398
  alignment of the referenced type. When `alignof` is applied to an array
1399
  type, the result is the alignment of the element type.
1400
 
1401
  #### `noexcept` operator <a id="expr.unary.noexcept">[[expr.unary.noexcept]]</a>
1402
 
1403
- The `noexcept` operator determines whether the evaluation of its
1404
- operand, which is an unevaluated operand [[term.unevaluated.operand]],
1405
- can throw an exception [[except.throw]].
1406
-
1407
  ``` bnf
1408
  noexcept-expression:
1409
  noexcept '(' expression ')'
1410
  ```
1411
 
1412
- The result of the `noexcept` operator is a prvalue of type `bool`.
 
 
 
 
 
 
1413
 
1414
  [*Note 1*: A *noexcept-expression* is an integral constant expression
1415
  [[expr.const]]. — *end note*]
1416
 
1417
- The result of the `noexcept` operator is `true` unless the *expression*
1418
- is potentially-throwing [[except.spec]].
1419
-
1420
  #### New <a id="expr.new">[[expr.new]]</a>
1421
 
1422
- The *new-expression* attempts to create an object of the *type-id*
1423
- [[dcl.name]] or *new-type-id* to which it is applied. The type of that
1424
  object is the *allocated type*. This type shall be a complete object
1425
  type [[term.incomplete.type]], but not an abstract class type
1426
  [[class.abstract]] or array thereof [[intro.object]].
1427
 
1428
  [*Note 1*: Because references are not objects, references cannot be
@@ -1464,17 +1536,17 @@ noptr-new-declarator:
1464
  new-initializer:
1465
  '(' expression-listₒₚₜ ')'
1466
  braced-init-list
1467
  ```
1468
 
1469
- If a placeholder type [[dcl.spec.auto]] appears in the
1470
- *type-specifier-seq* of a *new-type-id* or *type-id* of a
1471
- *new-expression*, the allocated type is deduced as follows: Let *init*
1472
- be the *new-initializer*, if any, and `T` be the *new-type-id* or
1473
- *type-id* of the *new-expression*, then the allocated type is the type
1474
- deduced for the variable `x` in the invented declaration
1475
- [[dcl.spec.auto]]:
1476
 
1477
  ``` cpp
1478
  T x init ;
1479
  ```
1480
 
@@ -1546,34 +1618,41 @@ converted constant expression [[expr.const]] of type `std::size_t` and
1546
  its value shall be greater than zero.
1547
 
1548
  [*Example 4*: Given the definition `int n = 42`, `new float[n][5]` is
1549
  well-formed (because `n` is the *expression* of a
1550
  *noptr-new-declarator*), but `new float[5][n]` is ill-formed (because
1551
- `n` is not a constant expression). *end example*]
 
 
 
 
 
1552
 
1553
  If the *type-id* or *new-type-id* denotes an array type of unknown bound
1554
  [[dcl.array]], the *new-initializer* shall not be omitted; the allocated
1555
  object is an array with `n` elements, where `n` is determined from the
1556
  number of initial elements supplied in the *new-initializer*
1557
  [[dcl.init.aggr]], [[dcl.init.string]].
1558
 
1559
  If the *expression* in a *noptr-new-declarator* is present, it is
1560
- implicitly converted to `std::size_t`. The *expression* is erroneous if:
 
1561
 
1562
  - the expression is of non-class type and its value before converting to
1563
  `std::size_t` is less than zero;
1564
  - the expression is of class type and its value before application of
1565
- the second standard conversion [[over.ics.user]][^23] is less than
1566
  zero;
1567
  - its value is such that the size of the allocated object would exceed
1568
  the *implementation-defined* limit [[implimits]]; or
1569
  - the *new-initializer* is a *braced-init-list* and the number of array
1570
  elements for which initializers are provided (including the
1571
  terminating `'\0'` in a *string-literal* [[lex.string]]) exceeds the
1572
  number of elements to initialize.
1573
 
1574
- If the *expression* is erroneous after converting to `std::size_t`:
 
1575
 
1576
  - if the *expression* is a potentially-evaluated core constant
1577
  expression, the program is ill-formed;
1578
  - otherwise, an allocation function is not called; instead
1579
  - if the allocation function that would have been called has a
@@ -1585,24 +1664,34 @@ If the *expression* is erroneous after converting to `std::size_t`:
1585
  `std::bad_array_new_length` [[new.badlength]].
1586
 
1587
  When the value of the *expression* is zero, the allocation function is
1588
  called to allocate an array with no elements.
1589
 
 
 
 
 
 
 
 
 
 
 
1590
  Objects created by a *new-expression* have dynamic storage duration
1591
  [[basic.stc.dynamic]].
1592
 
1593
- [*Note 5*: The lifetime of such an object is not necessarily
1594
  restricted to the scope in which it is created. — *end note*]
1595
 
1596
  When the allocated type is “array of `N` `T`” (that is, the
1597
  *noptr-new-declarator* syntax is used or the *new-type-id* or *type-id*
1598
  denotes an array type), the *new-expression* yields a prvalue of type
1599
  “pointer to `T`” that points to the initial element (if any) of the
1600
  array. Otherwise, let `T` be the allocated type; the *new-expression* is
1601
  a prvalue of type “pointer to T” that points to the object created.
1602
 
1603
- [*Note 6*: Both `new int` and `new int[10]` have type `int*` and the
1604
  type of `new int[i][10]` is `int (*)[10]`. — *end note*]
1605
 
1606
  A *new-expression* may obtain storage for the object by calling an
1607
  allocation function [[basic.stc.dynamic.allocation]]. If the
1608
  *new-expression* terminates by throwing an exception, it may release
@@ -1611,11 +1700,11 @@ storage by calling a deallocation function
1611
  type, the allocation function’s name is `operator new` and the
1612
  deallocation function’s name is `operator delete`. If the allocated type
1613
  is an array type, the allocation function’s name is `operator new[]` and
1614
  the deallocation function’s name is `operator delete[]`.
1615
 
1616
- [*Note 7*: An implementation is required to provide default definitions
1617
  for the global allocation functions
1618
  [[basic.stc.dynamic]], [[new.delete.single]], [[new.delete.array]]. A
1619
  C++ program can provide alternative definitions of these functions
1620
  [[replacement.functions]] and/or class-specific versions [[class.free]].
1621
  The set of allocation and deallocation functions that can be called by a
@@ -1632,16 +1721,12 @@ global scope.
1632
  An implementation is allowed to omit a call to a replaceable global
1633
  allocation function [[new.delete.single]], [[new.delete.array]]. When it
1634
  does so, the storage is instead provided by the implementation or
1635
  provided by extending the allocation of another *new-expression*.
1636
 
1637
- During an evaluation of a constant expression, a call to an allocation
1638
- function is always omitted.
1639
-
1640
- [*Note 8*: Only *new-expression*s that would otherwise result in a call
1641
- to a replaceable global allocation function can be evaluated in constant
1642
- expressions [[expr.const]]. — *end note*]
1643
 
1644
  The implementation may extend the allocation of a *new-expression* `e1`
1645
  to provide storage for a *new-expression* `e2` if the following would be
1646
  true were the allocation not extended:
1647
 
@@ -1780,13 +1865,13 @@ not be done, the deallocation function shall not be called, and the
1780
  value of the *new-expression* shall be null.
1781
 
1782
  [*Note 11*: When the allocation function returns a value other than
1783
  null, it must be a pointer to a block of storage in which space for the
1784
  object has been reserved. The block of storage is assumed to be
1785
- appropriately aligned and of the requested size. The address of the
1786
- created object will not necessarily be the same as that of the block if
1787
- the object is an array. — *end note*]
1788
 
1789
  A *new-expression* that creates an object of type `T` initializes that
1790
  object as follows:
1791
 
1792
  - If the *new-initializer* is omitted, the object is default-initialized
@@ -1798,18 +1883,14 @@ object as follows:
1798
  The invocation of the allocation function is sequenced before the
1799
  evaluations of expressions in the *new-initializer*. Initialization of
1800
  the allocated object is sequenced before the value computation of the
1801
  *new-expression*.
1802
 
1803
- If the *new-expression* creates an object or an array of objects of
1804
- class type, access and ambiguity control are done for the allocation
1805
- function, the deallocation function [[basic.stc.dynamic.deallocation]],
1806
- and the constructor [[class.ctor]] selected for the initialization (if
1807
- any). If the *new-expression* creates an array of objects of class type,
1808
- the destructor is potentially invoked [[class.dtor]].
1809
 
1810
- If any part of the object initialization described above[^24]
1811
 
1812
  terminates by throwing an exception and a suitable deallocation function
1813
  can be found, the deallocation function is called to free the memory in
1814
  which the object was being constructed, after which the exception
1815
  continues to propagate in the context of the *new-expression*. If no
@@ -1834,11 +1915,13 @@ single matching deallocation function, that function will be called;
1834
  otherwise, no deallocation function will be called. If the lookup finds
1835
  a usual deallocation function and that function, considered as a
1836
  placement deallocation function, would have been selected as a match for
1837
  the allocation function, the program is ill-formed. For a non-placement
1838
  allocation function, the normal deallocation function lookup is used to
1839
- find the matching deallocation function [[expr.delete]].
 
 
1840
 
1841
  [*Example 7*:
1842
 
1843
  ``` cpp
1844
  struct S {
@@ -1877,30 +1960,26 @@ delete-expression:
1877
  ```
1878
 
1879
  The first alternative is a *single-object delete expression*, and the
1880
  second is an *array delete expression*. Whenever the `delete` keyword is
1881
  immediately followed by empty square brackets, it shall be interpreted
1882
- as the second alternative.[^25]
1883
 
1884
- The operand shall be of pointer to object type or of class type. If of
1885
- class type, the operand is contextually implicitly converted [[conv]] to
1886
- a pointer to object type.[^26]
 
 
1887
 
1888
- The *delete-expression* has type `void`.
1889
-
1890
- If the operand has a class type, the operand is converted to a pointer
1891
- type by calling the above-mentioned conversion function, and the
1892
- converted operand is used in place of the original operand for the
1893
- remainder of this subclause. In a single-object delete expression, the
1894
- value of the operand of `delete` may be a null pointer value, a pointer
1895
- value that resulted from a previous non-array *new-expression*, or a
1896
- pointer to a base class subobject of an object created by such a
1897
- *new-expression*. If not, the behavior is undefined. In an array delete
1898
- expression, the value of the operand of `delete` may be a null pointer
1899
- value or a pointer value that resulted from a previous array
1900
- *new-expression* whose allocation function was not a non-allocating form
1901
- [[new.delete.placement]].[^27]
1902
 
1903
  If not, the behavior is undefined.
1904
 
1905
  [*Note 1*: This means that the syntax of the *delete-expression* must
1906
  match the type of the object allocated by `new`, not the syntax of the
@@ -1918,24 +1997,21 @@ delete, the static type shall be a base class of the dynamic type of the
1918
  object to be deleted and the static type shall have a virtual destructor
1919
  or the behavior is undefined. In an array delete expression, if the
1920
  dynamic type of the object to be deleted is not similar to its static
1921
  type, the behavior is undefined.
1922
 
1923
- The *cast-expression* in a *delete-expression* shall be evaluated
1924
- exactly once.
1925
-
1926
  If the object being deleted has incomplete class type at the point of
1927
- deletion and the complete class has a non-trivial destructor or a
1928
- deallocation function, the behavior is undefined.
1929
 
1930
  If the value of the operand of the *delete-expression* is not a null
1931
  pointer value and the selected deallocation function (see below) is not
1932
- a destroying operator delete, the *delete-expression* will invoke the
1933
- destructor (if any) for the object or the elements of the array being
1934
- deleted. In the case of an array, the elements will be destroyed in
1935
- order of decreasing address (that is, in reverse order of the completion
1936
- of their constructor; see  [[class.base.init]]).
 
1937
 
1938
  If the value of the operand of the *delete-expression* is not a null
1939
  pointer value, then:
1940
 
1941
  - If the allocation call for the *new-expression* for the object to be
@@ -1992,12 +2068,11 @@ declarations other than of usual deallocation functions
1992
 
1993
  [*Note 5*: If only a placement deallocation function is found in a
1994
  class, the program is ill-formed because the lookup set is empty
1995
  [[basic.lookup]]. — *end note*]
1996
 
1997
- If more than one deallocation function is found, the function to be
1998
- called is selected as follows:
1999
 
2000
  - If any of the deallocation functions is a destroying operator delete,
2001
  all deallocation functions that are not destroying operator deletes
2002
  are eliminated from further consideration.
2003
  - If the type has new-extended alignment, a function with a parameter of
@@ -2013,10 +2088,15 @@ called is selected as follows:
2013
  or a (possibly multidimensional) array thereof, the function with a
2014
  parameter of type `std::size_t` is selected.
2015
  - Otherwise, it is unspecified whether a deallocation function with a
2016
  parameter of type `std::size_t` is selected.
2017
 
 
 
 
 
 
2018
  For a single-object delete expression, the deleted object is the object
2019
  A pointed to by the operand if the static type of A does not have a
2020
  virtual destructor, and the most-derived object of A otherwise.
2021
 
2022
  [*Note 6*: If the deallocation function is not a destroying operator
@@ -2047,12 +2127,181 @@ passed as the corresponding argument.
2047
  function, and either the first argument was not the result of a prior
2048
  call to a replaceable allocation function or the second or third
2049
  argument was not the corresponding argument in said call, the behavior
2050
  is undefined [[new.delete.single]], [[new.delete.array]]. — *end note*]
2051
 
2052
- Access and ambiguity control are done for both the deallocation function
2053
- and the destructor [[class.dtor]], [[class.free]].
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2054
 
2055
  ### Explicit type conversion (cast notation) <a id="expr.cast">[[expr.cast]]</a>
2056
 
2057
  The result of the expression `(T)` *cast-expression* is of type `T`. The
2058
  result is an lvalue if `T` is an lvalue reference type or an rvalue
@@ -2102,12 +2351,13 @@ conversion is valid even if the base class is inaccessible:
2102
  of a derived class type, respectively.
2103
 
2104
  If a conversion can be interpreted in more than one of the ways listed
2105
  above, the interpretation that appears first in the list is used, even
2106
  if a cast resulting from that interpretation is ill-formed. If a
2107
- conversion can be interpreted in more than one way as a `static_cast`
2108
- followed by a `const_cast`, the conversion is ill-formed.
 
2109
 
2110
  [*Example 1*:
2111
 
2112
  ``` cpp
2113
  struct A { };
@@ -2115,10 +2365,19 @@ struct I1 : A { };
2115
  struct I2 : A { };
2116
  struct D : I1, I2 { };
2117
  A* foo( D* p ) {
2118
  return (A*)( p ); // ill-formed static_cast interpretation
2119
  }
 
 
 
 
 
 
 
 
 
2120
  ```
2121
 
2122
  — *end example*]
2123
 
2124
  The operand of a cast using the cast notation can be a prvalue of type
@@ -2128,13 +2387,13 @@ operand and destination types are class types and one or both are
2128
  incomplete, it is unspecified whether the `static_cast` or the
2129
  `reinterpret_cast` interpretation is used, even if there is an
2130
  inheritance relationship between the two classes.
2131
 
2132
  [*Note 2*: For example, if the classes were defined later in the
2133
- translation unit, a multi-pass compiler would be permitted to interpret
2134
- a cast between pointers to the classes as if the class types were
2135
- complete at the point of the cast. — *end note*]
2136
 
2137
  ### Pointer-to-member operators <a id="expr.mptr.oper">[[expr.mptr.oper]]</a>
2138
 
2139
  The pointer-to-member operators `->*` and `.*` group left-to-right.
2140
 
@@ -2143,21 +2402,21 @@ pm-expression:
2143
  cast-expression
2144
  pm-expression '.*' cast-expression
2145
  pm-expression '->*' cast-expression
2146
  ```
2147
 
2148
- The binary operator `.*` binds its second operand, which shall be of
2149
- type “pointer to member of `T`” to its first operand, which shall be a
2150
- glvalue of class `T` or of a class of which `T` is an unambiguous and
2151
- accessible base class. The result is an object or a function of the type
2152
- specified by the second operand.
2153
 
2154
- The binary operator `->*` binds its second operand, which shall be of
2155
- type “pointer to member of `T`” to its first operand, which shall be of
2156
- type “pointer to `U`” where `U` is either `T` or a class of which `T` is
2157
- an unambiguous and accessible base class. The expression `E1->*E2` is
2158
- converted into the equivalent form `(*(E1)).*E2`.
2159
 
2160
  Abbreviating *pm-expression*`.*`*cast-expression* as `E1.*E2`, `E1` is
2161
  called the *object expression*. If the result of `E1` is an object whose
2162
  type is not similar to the type of `E1`, or whose most derived object
2163
  does not contain the member to which `E2` refers, the behavior is
@@ -2233,77 +2492,80 @@ are performed on the operands and determine the type of the result.
2233
 
2234
  The binary `*` operator indicates multiplication.
2235
 
2236
  The binary `/` operator yields the quotient, and the binary `%` operator
2237
  yields the remainder from the division of the first expression by the
2238
- second. If the second operand of `/` or `%` is zero the behavior is
2239
- undefined. For integral operands the `/` operator yields the algebraic
2240
- quotient with any fractional part discarded;[^28]
2241
 
2242
  if the quotient `a/b` is representable in the type of the result,
2243
  `(a/b)*b + a%b` is equal to `a`; otherwise, the behavior of both `a/b`
2244
  and `a%b` is undefined.
2245
 
2246
  ### Additive operators <a id="expr.add">[[expr.add]]</a>
2247
 
2248
- The additive operators `+` and `-` group left-to-right. The usual
2249
- arithmetic conversions [[expr.arith.conv]] are performed for operands of
2250
- arithmetic or enumeration type.
 
 
 
 
2251
 
2252
  ``` bnf
2253
  additive-expression:
2254
  multiplicative-expression
2255
  additive-expression '+' multiplicative-expression
2256
  additive-expression '-' multiplicative-expression
2257
  ```
2258
 
2259
- For addition, either both operands shall have arithmetic or unscoped
2260
- enumeration type, or one operand shall be a pointer to a
2261
- completely-defined object type and the other shall have integral or
2262
- unscoped enumeration type.
2263
 
2264
  For subtraction, one of the following shall hold:
2265
 
2266
- - both operands have arithmetic or unscoped enumeration type; or
2267
  - both operands are pointers to cv-qualified or cv-unqualified versions
2268
  of the same completely-defined object type; or
2269
  - the left operand is a pointer to a completely-defined object type and
2270
- the right operand has integral or unscoped enumeration type.
2271
 
2272
  The result of the binary `+` operator is the sum of the operands. The
2273
  result of the binary `-` operator is the difference resulting from the
2274
  subtraction of the second operand from the first.
2275
 
2276
  When an expression `J` that has integral type is added to or subtracted
2277
  from an expression `P` of pointer type, the result has the type of `P`.
2278
 
2279
  - If `P` evaluates to a null pointer value and `J` evaluates to 0, the
2280
  result is a null pointer value.
2281
- - Otherwise, if `P` points to an array element i of an array object `x`
2282
- with n elements [[dcl.array]],[^29] the expressions `P + J` and
2283
- `J + P` (where `J` has the value j) point to the
2284
- (possibly-hypothetical) array element i + j of `x` if 0 ≤ i + j ≤ n
2285
- and the expression `P - J` points to the (possibly-hypothetical) array
2286
- element i - j of `x` if 0 ≤ i - j ≤ n.
2287
  - Otherwise, the behavior is undefined.
2288
 
2289
  [*Note 1*: Adding a value other than 0 or 1 to a pointer to a base
2290
  class subobject, a member subobject, or a complete object results in
2291
  undefined behavior. — *end note*]
2292
 
2293
  When two pointer expressions `P` and `Q` are subtracted, the type of the
2294
  result is an *implementation-defined* signed integral type; this type
2295
- shall be the same type that is defined as `std::ptrdiff_t` in the
2296
  `<cstddef>` header [[support.types.layout]].
2297
 
2298
  - If `P` and `Q` both evaluate to null pointer values, the result is 0.
2299
  - Otherwise, if `P` and `Q` point to, respectively, array elements i and
2300
  j of the same array object `x`, the expression `P - Q` has the value
2301
- i - j.
2302
- - Otherwise, the behavior is undefined. \[*Note 2*: If the value i - j
2303
- is not in the range of representable values of type `std::ptrdiff_t`,
2304
- the behavior is undefined. — *end note*]
2305
 
2306
  For addition or subtraction, if the expressions `P` or `Q` have type
2307
  “pointer to cv `T`”, where `T` and the array element type are not
2308
  similar [[conv.qual]], the behavior is undefined.
2309
 
@@ -2327,23 +2589,24 @@ shift-expression:
2327
  additive-expression
2328
  shift-expression '<<' additive-expression
2329
  shift-expression '>>' additive-expression
2330
  ```
2331
 
2332
- The operands shall be of integral or unscoped enumeration type and
2333
- integral promotions are performed. The type of the result is that of the
2334
- promoted left operand. The behavior is undefined if the right operand is
2335
- negative, or greater than or equal to the width of the promoted left
2336
- operand.
2337
 
2338
  The value of `E1 << E2` is the unique value congruent to `E1` × 2^`E2`
2339
  modulo 2ᴺ, where N is the width of the type of the result.
2340
 
2341
  [*Note 1*: `E1` is left-shifted `E2` bit positions; vacated bits are
2342
  zero-filled. — *end note*]
2343
 
2344
- The value of `E1 >> E2` is `E1` / 2^`E2`, rounded down.
 
2345
 
2346
  [*Note 2*: `E1` is right-shifted `E2` bit positions. Right-shift on
2347
  signed integral types is an arithmetic right shift, which performs
2348
  sign-extension. — *end note*]
2349
 
@@ -2436,28 +2699,28 @@ relational-expression:
2436
  relational-expression '>' compare-expression
2437
  relational-expression '<=' compare-expression
2438
  relational-expression '>=' compare-expression
2439
  ```
2440
 
2441
- The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
2442
- function-to-pointer [[conv.func]] standard conversions are performed on
2443
- the operands. The comparison is deprecated if both operands were of
2444
- array type prior to these conversions [[depr.array.comp]].
2445
 
2446
  The converted operands shall have arithmetic, enumeration, or pointer
2447
  type. The operators `<` (less than), `>` (greater than), `<=` (less than
2448
  or equal to), and `>=` (greater than or equal to) all yield `false` or
2449
  `true`. The type of the result is `bool`.
2450
 
2451
  The usual arithmetic conversions [[expr.arith.conv]] are performed on
2452
- operands of arithmetic or enumeration type. If both operands are
2453
- pointers, pointer conversions [[conv.ptr]] and qualification conversions
2454
- [[conv.qual]] are performed to bring them to their composite pointer
2455
- type [[expr.type]]. After conversions, the operands shall have the same
2456
- type.
2457
 
2458
- The result of comparing unequal pointers to objects[^30]
2459
 
2460
  is defined in terms of a partial order consistent with the following
2461
  rules:
2462
 
2463
  - If two pointers point to different elements of the same array, or to
@@ -2477,12 +2740,12 @@ a pointer to object `p` compares greater than a pointer `q`, `p>=q`,
2477
  `p>q`, `q<=p`, and `q<p` all yield `true` and `p<=q`, `p<q`, `q>=p`, and
2478
  `q>p` all yield `false`. Otherwise, the result of each of the operators
2479
  is unspecified.
2480
 
2481
  [*Note 1*: A relational operator applied to unequal function pointers
2482
- or to unequal pointers to `void` yields an unspecified
2483
- result. — *end note*]
2484
 
2485
  If both operands (after conversions) are of arithmetic or enumeration
2486
  type, each of the operators shall yield `true` if the specified
2487
  relationship is true and `false` if it is false.
2488
 
@@ -2494,31 +2757,30 @@ equality-expression:
2494
  equality-expression '==' relational-expression
2495
  equality-expression '!=' relational-expression
2496
  ```
2497
 
2498
  The `==` (equal to) and the `!=` (not equal to) operators group
2499
- left-to-right. The lvalue-to-rvalue [[conv.lval]], array-to-pointer
2500
- [[conv.array]], and function-to-pointer [[conv.func]] standard
2501
- conversions are performed on the operands. The comparison is deprecated
2502
- if both operands were of array type prior to these conversions
2503
- [[depr.array.comp]].
2504
 
2505
- The converted operands shall have arithmetic, enumeration, pointer, or
2506
- pointer-to-member type, or type `std::nullptr_t`. The operators `==` and
2507
  `!=` both yield `true` or `false`, i.e., a result of type `bool`. In
2508
  each case below, the operands shall have the same type after the
2509
  specified conversions have been applied.
2510
 
2511
- If at least one of the operands is a pointer, pointer conversions
2512
- [[conv.ptr]], function pointer conversions [[conv.fctptr]], and
2513
- qualification conversions [[conv.qual]] are performed on both operands
2514
- to bring them to their composite pointer type [[expr.type]]. Comparing
2515
- pointers is defined as follows:
2516
 
2517
  - If one pointer represents the address of a complete object, and
2518
  another pointer represents the address one past the last element of a
2519
- different complete object,[^31] the result of the comparison is
2520
  unspecified.
2521
  - Otherwise, if the pointers are both null, both point to the same
2522
  function, or both represent the same address [[basic.compound]], they
2523
  compare equal.
2524
  - Otherwise, the pointers compare unequal.
@@ -2578,10 +2840,23 @@ performed on both operands to bring them to their composite pointer type
2578
  — *end example*]
2579
 
2580
  Two operands of type `std::nullptr_t` or one operand of type
2581
  `std::nullptr_t` and the other a null pointer constant compare equal.
2582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2583
  If two operands compare equal, the result is `true` for the `==`
2584
  operator and `false` for the `!=` operator. If two operands compare
2585
  unequal, the result is `false` for the `==` operator and `true` for the
2586
  `!=` operator. Otherwise, the result of each of the operators is
2587
  unspecified.
@@ -2736,33 +3011,36 @@ type `T2` of the operand expression `E2` as follows:
2736
  but an implicit conversion sequence can only be formed if the
2737
  reference would bind directly.
2738
  - If `E2` is a prvalue or if neither of the conversion sequences above
2739
  can be formed and at least one of the operands has (possibly
2740
  cv-qualified) class type:
2741
- - if `T1` and `T2` are the same class type (ignoring cv-qualification)
2742
- and `T2` is at least as cv-qualified as `T1`, the target type is
 
2743
  `T2`,
 
2744
  - otherwise, if `T2` is a base class of `T1`, the target type is *cv1*
2745
- `T2`, where *cv1* denotes the cv-qualifiers of `T1`,
2746
  - otherwise, the target type is the type that `E2` would have after
2747
  applying the lvalue-to-rvalue [[conv.lval]], array-to-pointer
2748
  [[conv.array]], and function-to-pointer [[conv.func]] standard
2749
  conversions.
2750
 
2751
  Using this process, it is determined whether an implicit conversion
2752
  sequence can be formed from the second operand to the target type
2753
- determined for the third operand, and vice versa. If both sequences can
2754
- be formed, or one can be formed but it is the ambiguous conversion
2755
- sequence, the program is ill-formed. If no conversion sequence can be
2756
- formed, the operands are left unchanged and further checking is
2757
- performed as described below. Otherwise, if exactly one conversion
2758
- sequence can be formed, that conversion is applied to the chosen operand
2759
- and the converted operand is used in place of the original operand for
2760
- the remainder of this subclause.
2761
 
2762
- [*Note 3*: The conversion might be ill-formed even if an implicit
2763
- conversion sequence could be formed. — *end note*]
 
 
 
 
 
 
 
2764
 
2765
  If the second and third operands are glvalues of the same value category
2766
  and have the same type, the result is of that type and value category
2767
  and it is a bit-field if the second or the third operand is a bit-field,
2768
  or if both are bit-fields.
@@ -2774,41 +3052,40 @@ to be applied to the operands [[over.match.oper]], [[over.built]]. If
2774
  the overload resolution fails, the program is ill-formed. Otherwise, the
2775
  conversions thus determined are applied, and the converted operands are
2776
  used in place of the original operands for the remainder of this
2777
  subclause.
2778
 
2779
- Lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
2780
- function-to-pointer [[conv.func]] standard conversions are performed on
2781
- the second and third operands. After those conversions, one of the
2782
- following shall hold:
2783
 
2784
  - The second and third operands have the same type; the result is of
2785
- that type and the result object is initialized using the selected
2786
  operand.
2787
  - The second and third operands have arithmetic or enumeration type; the
2788
  usual arithmetic conversions [[expr.arith.conv]] are performed to
2789
  bring them to a common type, and the result is of that type.
2790
  - One or both of the second and third operands have pointer type;
2791
- pointer conversions [[conv.ptr]], function pointer conversions
2792
  [[conv.fctptr]], and qualification conversions [[conv.qual]] are
2793
  performed to bring them to their composite pointer type [[expr.type]].
2794
  The result is of the composite pointer type.
2795
  - One or both of the second and third operands have pointer-to-member
2796
- type; pointer to member conversions [[conv.mem]], function pointer
2797
- conversions [[conv.fctptr]], and qualification conversions
2798
  [[conv.qual]] are performed to bring them to their composite pointer
2799
  type [[expr.type]]. The result is of the composite pointer type.
2800
  - Both the second and third operands have type `std::nullptr_t` or one
2801
  has that type and the other is a null pointer constant. The result is
2802
  of type `std::nullptr_t`.
2803
 
2804
  ### Yielding a value <a id="expr.yield">[[expr.yield]]</a>
2805
 
2806
  ``` bnf
2807
  yield-expression:
2808
- 'co_yield' assignment-expression
2809
- 'co_yield' braced-init-list
2810
  ```
2811
 
2812
  A *yield-expression* shall appear only within a suspension context of a
2813
  function [[expr.await]]. Let *e* be the operand of the
2814
  *yield-expression* and *p* be an lvalue naming the promise object of the
@@ -2860,20 +3137,24 @@ throw-expression:
2860
  throw assignment-expressionₒₚₜ
2861
  ```
2862
 
2863
  A *throw-expression* is of type `void`.
2864
 
2865
- Evaluating a *throw-expression* with an operand throws an exception
2866
- [[except.throw]]; the type of the exception object is determined by
2867
- removing any top-level *cv-qualifier*s from the static type of the
2868
- operand and adjusting the type from “array of `T`” or function type `T`
2869
- to “pointer to `T`”.
 
 
2870
 
2871
  A *throw-expression* with no operand rethrows the currently handled
2872
- exception [[except.handle]]. The exception is reactivated with the
2873
- existing exception object; no new exception object is created. The
2874
- exception is no longer considered to be caught.
 
 
2875
 
2876
  [*Example 1*:
2877
 
2878
  An exception handler that cannot completely handle the exception itself
2879
  can be written like this:
@@ -2887,15 +3168,11 @@ try {
2887
  }
2888
  ```
2889
 
2890
  — *end example*]
2891
 
2892
- If no exception is presently being handled, evaluating a
2893
- *throw-expression* with no operand calls `std::{}terminate()`
2894
- [[except.terminate]].
2895
-
2896
- ### Assignment and compound assignment operators <a id="expr.ass">[[expr.ass]]</a>
2897
 
2898
  The assignment operator (`=`) and the compound assignment operators all
2899
  group right-to-left. All require a modifiable lvalue as their left
2900
  operand; their result is an lvalue of the type of the left operand,
2901
  referring to the left operand. The result in all cases is a bit-field if
@@ -2921,13 +3198,14 @@ assignment-expression:
2921
  ``` bnf
2922
  assignment-operator: one of
2923
  '= *= /= %= += -= >>= <<= &= ^= |='
2924
  ```
2925
 
2926
- In simple assignment (`=`), the object referred to by the left operand
2927
- is modified [[defns.access]] by replacing its value with the result of
2928
- the right operand.
 
2929
 
2930
  If the right operand is an expression, it is implicitly converted
2931
  [[conv]] to the cv-unqualified type of the left operand.
2932
 
2933
  When the left operand of an assignment operator is a bit-field that
@@ -2957,19 +3235,18 @@ the behavior is undefined.
2957
  [*Note 3*: This restriction applies to the relationship between the
2958
  left and right sides of the assignment operation; it is not a statement
2959
  about how the target of the assignment can be aliased in general. See 
2960
  [[basic.lval]]. — *end note*]
2961
 
2962
- A *braced-init-list* may appear on the right-hand side of
2963
 
2964
- - an assignment to a scalar, in which case the initializer list shall
2965
- have at most a single element. The meaning of `x = {v}`, where `T` is
2966
- the scalar type of the expression `x`, is that of `x = T{v}`. The
2967
- meaning of `x = {}` is `x = T{}`.
2968
- - an assignment to an object of class type, in which case the
2969
- initializer list is passed as the argument to the assignment operator
2970
- function selected by overload resolution [[over.ass]], [[over.match]].
2971
 
2972
  [*Example 1*:
2973
 
2974
  ``` cpp
2975
  complex<double> z;
 
13
  postfix-expression '(' expression-listₒₚₜ ')'
14
  simple-type-specifier '(' expression-listₒₚₜ ')'
15
  typename-specifier '(' expression-listₒₚₜ ')'
16
  simple-type-specifier braced-init-list
17
  typename-specifier braced-init-list
18
+ postfix-expression '.' templateₒₚₜ id-expression
19
+ postfix-expression '.' splice-expression
20
+ postfix-expression '->' templateₒₚₜ id-expression
21
+ postfix-expression '->' splice-expression
22
  postfix-expression '++'
23
  postfix-expression '--'
24
  dynamic_cast '<' type-id '>' '(' expression ')'
25
  static_cast '<' type-id '>' '(' expression ')'
26
  reinterpret_cast '<' type-id '>' '(' expression ')'
 
43
 
44
  A *subscript expression* is a postfix expression followed by square
45
  brackets containing a possibly empty, comma-separated list of
46
  *initializer-clause*s that constitute the arguments to the subscript
47
  operator. The *postfix-expression* and the initialization of the object
48
+ parameter [[dcl.fct]] of any applicable subscript operator function
49
+ [[over.sub]] is sequenced before each expression in the
50
+ *expression-list* and also before any default argument
51
+ [[dcl.fct.default]]. The initialization of a non-object parameter of a
52
+ subscript operator function `S`, including every associated value
53
+ computation and side effect, is indeterminately sequenced with respect
54
+ to that of any other non-object parameter of `S`.
55
 
56
  With the built-in subscript operator, an *expression-list* shall be
57
  present, consisting of a single *assignment-expression*. One of the
58
  expressions shall be a glvalue of type “array of `T`” or a prvalue of
59
  type “pointer to `T`” and the other shall be a prvalue of unscoped
60
  enumeration or integral type. The result is of type “`T`”. The type
61
+ “`T`” shall be a completely-defined object type.[^10]
62
 
63
  The expression `E1[E2]` is identical (by definition) to `*((E1)+(E2))`,
64
  except that in the case of an array operand, the result is an lvalue if
65
  that operand is an lvalue and an xvalue otherwise.
66
 
 
73
 
74
  A function call is a postfix expression followed by parentheses
75
  containing a possibly empty, comma-separated list of
76
  *initializer-clause*s which constitute the arguments to the function.
77
 
78
+ [*Note 1*: If the postfix expression is a function name, the
79
+ appropriate function and the validity of the call are determined
80
+ according to the rules in  [[over.match]]. — *end note*]
81
 
82
  The postfix expression shall have function type or function pointer
83
  type. For a call to a non-member function or to a static member
84
+ function, the postfix expression shall be either an lvalue that refers
85
  to a function (in which case the function-to-pointer standard conversion
86
+ [[conv.func]] is suppressed on the postfix expression), or a prvalue of
87
+ function pointer type.
88
 
89
  If the selected function is non-virtual, or if the *id-expression* in
90
  the class member access expression is a *qualified-id*, that function is
91
  called. Otherwise, its final overrider [[class.virtual]] in the dynamic
92
  type of the object expression is called; such a call is referred to as a
 
95
  [*Note 2*: The dynamic type is the type of the object referred to by
96
  the current value of the object expression. [[class.cdtor]] describes
97
  the behavior of virtual function calls when the object expression refers
98
  to an object under construction or destruction. — *end note*]
99
 
100
+ [*Note 3*: If a function name is used, and name lookup [[basic.lookup]]
101
+ does not find a declaration of that name, the program is ill-formed. No
102
+ function is implicitly declared by such a call. — *end note*]
 
103
 
104
  If the *postfix-expression* names a destructor or pseudo-destructor
105
  [[expr.prim.id.dtor]], the type of the function call expression is
106
  `void`; otherwise, the type of the function call expression is the
107
  return type of the statically chosen function (i.e., ignoring the
 
110
  which case the *postfix-expression* is a possibly-parenthesized class
111
  member access), the function call destroys the object of scalar type
112
  denoted by the object expression of the class member access
113
  [[expr.ref]], [[basic.life]].
114
 
115
+ A type `T`_call is *call-compatible* with a function type `T`_func if
116
+ `T`_call is the same type as `T`_func or if the type “pointer to
117
+ `T`_func” can be converted to type “pointer to `T`_callvia a function
118
+ pointer conversion [[conv.fctptr]]. Calling a function through an
119
+ expression whose function type is not call-compatible with the type of
120
+ the called function’s definition results in undefined behavior.
121
 
122
+ [*Note 4*: This requirement allows the case when the expression has the
123
+ type of a potentially-throwing function, but the called function has a
124
  non-throwing exception specification, and the function types are
125
  otherwise the same. — *end note*]
126
 
127
  When a function is called, each parameter [[dcl.fct]] is initialized
128
+ [[dcl.init]], [[class.copy.ctor]] with its corresponding argument, and
129
+ each precondition assertion of the function is evaluated
130
+ [[dcl.contract.func]]. If the function is an explicit object member
131
+ function and there is an implied object argument [[over.call.func]], the
132
+ list of provided arguments is preceded by the implied object argument
133
+ for the purposes of this correspondence. If there is no corresponding
134
+ argument, the default argument for the parameter is used.
135
 
136
  [*Example 1*:
137
 
138
  ``` cpp
139
  template<typename ...T> int f(int n = 0, T ...t);
140
  int x = f<int>(); // error: no argument for second function parameter
141
  ```
142
 
143
  — *end example*]
144
 
145
+ If the function is an implicit object member function, the object
146
+ expression of the class member access shall be a glvalue and the
147
+ implicit object parameter of the function [[over.match.funcs]] is
148
+ initialized with that glvalue, converted as if by an explicit type
149
  conversion [[expr.cast]].
150
 
151
  [*Note 5*: There is no access or ambiguity checking on this conversion;
152
  the access checking and disambiguation are done as part of the (possibly
153
  implicit) class member access operator. See  [[class.member.lookup]],
 
158
 
159
  [*Note 6*: This still allows a parameter to be a pointer or reference
160
  to such a type. However, it prevents a passed-by-value parameter to have
161
  an incomplete or abstract class type. — *end note*]
162
 
163
+ It is *implementation-defined* whether a parameter is destroyed when the
164
+ function in which it is defined exits
165
+ [[stmt.return]], [[except.ctor]], [[expr.await]] or at the end of the
166
+ enclosing full-expression; parameters are always destroyed in the
167
+ reverse order of their construction. The initialization and destruction
168
+ of each parameter occurs within the context of the full-expression
169
+ [[intro.execution]] where the function call appears.
170
 
171
+ [*Example 2*: The access [[class.access.general]] of the constructor,
172
+ conversion functions, or destructor is checked at the point of call. If
173
+ a constructor or destructor for a function parameter throws an
174
+ exception, any *function-try-block* [[except.pre]] of the called
175
+ function with a handler that can handle the exception is not
 
176
  considered. — *end example*]
177
 
178
  The *postfix-expression* is sequenced before each *expression* in the
179
  *expression-list* and any default argument. The initialization of a
180
+ parameter or, if the implementation introduces any temporary objects to
181
+ hold the values of function parameters [[class.temporary]], the
182
+ initialization of those temporaries, including every associated value
183
+ computation and side effect, is indeterminately sequenced with respect
184
+ to that of any other parameter. These evaluations are sequenced before
185
+ the evaluation of the precondition assertions of the function, which are
186
+ evaluated in sequence [[dcl.contract.func]]. For any temporaries
187
+ introduced to hold the values of function parameters, the initialization
188
+ of the parameter objects from those temporaries is indeterminately
189
+ sequenced with respect to the evaluation of each precondition assertion.
190
 
191
  [*Note 7*: All side effects of argument evaluations are sequenced
192
  before the function is entered (see 
193
  [[intro.execution]]). — *end note*]
194
 
 
232
  function call if the return type of the final overrider is different
233
  from the return type of the statically chosen function, the value
234
  returned from the final overrider is converted to the return type of the
235
  statically chosen function.
236
 
237
+ When the called function exits normally [[stmt.return]], [[expr.await]],
238
+ all postcondition assertions of the function are evaluated in sequence
239
+ [[dcl.contract.func]]. If the implementation introduces any temporary
240
+ objects to hold the result value as specified in [[class.temporary]],
241
+ the evaluation of each postcondition assertion is indeterminately
242
+ sequenced with respect to the initialization of any of those temporaries
243
+ or the result object. These evaluations, in turn, are sequenced before
244
+ the destruction of any function parameters.
245
+
246
  [*Note 9*: A function can change the values of its non-const
247
  parameters, but these changes cannot affect the values of the arguments
248
  except where a parameter is of a reference type [[dcl.ref]]; if the
249
+ reference is to a const-qualified type, `const_cast` needs to be used to
250
+ cast away the constness in order to modify the argument’s value. Where a
251
+ parameter is of `const` reference type a temporary object is introduced
252
+ if needed
253
  [[dcl.type]], [[lex.literal]], [[lex.string]], [[dcl.array]], [[class.temporary]].
254
  In addition, it is possible to modify the values of non-constant objects
255
  through pointer parameters. — *end note*]
256
 
257
  A function can be declared to accept fewer arguments (by declaring
 
277
  function-to-pointer [[conv.func]] standard conversions are performed on
278
  the argument expression. An argument that has type cv `std::nullptr_t`
279
  is converted to type `void*` [[conv.ptr]]. After these conversions, if
280
  the argument does not have arithmetic, enumeration, pointer,
281
  pointer-to-member, or class type, the program is ill-formed. Passing a
282
+ potentially-evaluated argument of a scoped enumeration type [[dcl.enum]]
283
+ or of a class type [[class]] having an eligible non-trivial copy
284
+ constructor [[special]], [[class.copy.ctor]], an eligible non-trivial
285
+ move constructor, or a non-trivial destructor [[class.dtor]], with no
286
+ corresponding parameter, is conditionally-supported with
287
+ *implementation-defined* semantics. If the argument has integral or
288
  enumeration type that is subject to the integral promotions
289
  [[conv.prom]], or a floating-point type that is subject to the
290
  floating-point promotion [[conv.fpprom]], the value of the argument is
291
  converted to the promoted type before the call. These promotions are
292
  referred to as the *default argument promotions*.
 
294
  Recursive calls are permitted, except to the `main` function
295
  [[basic.start.main]].
296
 
297
  A function call is an lvalue if the result type is an lvalue reference
298
  type or an rvalue reference to function type, an xvalue if the result
299
+ type is an rvalue reference to object type, and a prvalue otherwise. If
300
+ it is a non-void prvalue, the type of the function call expression shall
301
+ be complete, except as specified in [[dcl.type.decltype]].
302
 
303
  #### Explicit type conversion (functional notation) <a id="expr.type.conv">[[expr.type.conv]]</a>
304
 
305
  A *simple-type-specifier* [[dcl.type.simple]] or *typename-specifier*
306
  [[temp.res]] followed by a parenthesized optional *expression-list* or
 
309
  deduced class type, it is replaced by the return type of the function
310
  selected by overload resolution for class template deduction
311
  [[over.match.class.deduct]] for the remainder of this subclause.
312
  Otherwise, if the type contains a placeholder type, it is replaced by
313
  the type determined by placeholder type deduction
314
+ [[dcl.type.auto.deduct]]. Let `T` denote the resulting type. Then:
315
+
316
+ - If the initializer is a parenthesized single expression, the type
317
+ conversion expression is equivalent to the corresponding cast
318
+ expression [[expr.cast]].
319
+ - Otherwise, if `T` is cv `void`, the initializer shall be `()` or `{}`
320
+ (after pack expansion, if any), and the expression is a prvalue of
321
+ type `void` that performs no initialization.
322
+ - Otherwise, if `T` is a reference type, the expression has the same
323
+ effect as direct-initializing an invented variable `t` of type `T`
324
+ from the initializer and then using `t` as the result of the
325
+ expression; the result is an lvalue if `T` is an lvalue reference type
326
+ or an rvalue reference to function type and an xvalue otherwise.
327
+ - Otherwise, the expression is a prvalue of type `T` whose result object
328
+ is direct-initialized [[dcl.init]] with the initializer.
329
+
330
+ If the initializer is a parenthesized optional *expression-list*, `T`
331
+ shall not be an array type.
332
 
333
  [*Example 1*:
334
 
335
  ``` cpp
336
  struct A {};
 
344
  }
345
  ```
346
 
347
  — *end example*]
348
 
 
 
 
 
 
 
 
 
 
 
349
  #### Class member access <a id="expr.ref">[[expr.ref]]</a>
350
 
351
  A postfix expression followed by a dot `.` or an arrow `->`, optionally
352
  followed by the keyword `template`, and then followed by an
353
+ *id-expression* or a *splice-expression*, is a postfix expression.
 
354
 
355
+ [*Note 1*: If the keyword `template` is used and followed by an
356
+ *id-expression*, the unqualified name is considered to refer to a
357
+ template [[temp.names]]. If a *simple-template-id* results and is
358
+ followed by a `::`, the *id-expression* is a
359
+ *qualified-id*. — *end note*]
360
 
361
+ For a dot that is followed by an expression that designates a static
362
+ member or an enumerator, the first expression is a discarded-value
363
+ expression [[expr.context]]; if the expression after the dot designates
364
+ a non-static data member, the first expression shall be a glvalue. A
365
+ postfix expression that is followed by an arrow shall be a prvalue
366
+ having pointer type. The expression `E1->E2` is converted to the
367
+ equivalent form `(*(E1)).E2`; the remainder of [[expr.ref]] will address
368
+ only the form using a dot.[^11]
369
 
370
+ The postfix expression before the dot is evaluated;[^12]
 
 
 
 
371
 
372
+ the result of that evaluation, together with the *id-expression* or
373
+ *splice-expression*, determines the result of the entire postfix
374
+ expression.
375
+
376
+ Abbreviating *postfix-expression*`.`*id-expression* or
377
+ *postfix-expression*`.`*splice-expression* as `E1.E2`, `E1` is called
378
+ the *object expression*. If the object expression is of scalar type,
379
+ `E2` shall name the pseudo-destructor of that same type (ignoring
380
  cv-qualifications) and `E1.E2` is a prvalue of type “function of ()
381
  returning `void`”.
382
 
383
  [*Note 2*: This value can only be used for a notional function call
384
  [[expr.prim.id.dtor]]. — *end note*]
 
391
  when the class is complete [[class.member.lookup]]. — *end note*]
392
 
393
  [*Note 4*: [[basic.lookup.qual]] describes how names are looked up
394
  after the `.` and `->` operators. — *end note*]
395
 
396
+ If `E2` is a *splice-expression*, then let `T1` be the type of `E1`.
397
+ `E2` shall designate either a member of `T1` or a direct base class
398
+ relationship (`T1`, `B`).
 
 
 
399
 
400
+ If `E2` designates a bit-field, `E1.E2` is a bit-field. The type and
401
+ value category of `E1.E2` are determined as follows. In the remainder
402
+ of  [[expr.ref]], *cq* represents either `const` or the absence of
403
+ `const` and *vq* represents either `volatile` or the absence of
404
+ `volatile`. *cv* represents an arbitrary set of cv-qualifiers, as
405
+ defined in  [[basic.type.qualifier]].
406
 
407
+ If `E2` designates an entity that is declared to have type “reference to
408
+ `T`”, then `E1.E2` is an lvalue of type `T`. In that case, if `E2`
409
+ designates a static data member, `E1.E2` designates the object or
410
+ function to which the reference is bound, otherwise `E1.E2` designates
411
+ the object or function to which the corresponding reference member of
412
+ `E1` is bound. Otherwise, one of the following rules applies.
413
+
414
+ - If `E2` designates a static data member and the type of `E2` is `T`,
415
+ then `E1.E2` is an lvalue; the expression designates the named member
416
+ of the class. The type of `E1.E2` is `T`.
417
+ - Otherwise, if `E2` designates a non-static data member and the type of
418
+ `E1` is *cq1 vq1* `X`”, and the type of `E2` is “*cq2 vq2* `T`”, the
419
+ expression designates the corresponding member subobject of the object
420
+ designated by `E1`. If `E1` is an lvalue, then `E1.E2` is an lvalue;
421
+ otherwise `E1.E2` is an xvalue. Let the notation *vq12* stand for the
422
+ “union” of *vq1* and *vq2*; that is, if *vq1* or *vq2* is `volatile`,
423
+ then *vq12* is `volatile`. Similarly, let the notation *cq12* stand
424
+ for the “union” of *cq1* and *cq2*; that is, if *cq1* or *cq2* is
425
+ `const`, then *cq12* is `const`. If the entity designated by `E2` is
426
+ declared to be a `mutable` member, then the type of `E1.E2` is “*vq12*
427
+ `T`”. If the entity designated by `E2` is not declared to be a
428
+ `mutable` member, then the type of `E1.E2` is “*cq12* *vq12* `T`”.
429
+ - Otherwise, if `E2` denotes an overload set, the expression shall be
430
+ the (possibly-parenthesized) left-hand operand of a member function
431
+ call [[expr.call]], and function overload resolution [[over.match]] is
432
+ used to select the function to which `E2` refers. The type of `E1.E2`
433
+ is the type of `E2` and `E1.E2` refers to the function referred to by
434
+ `E2`.
435
  - If `E2` refers to a static member function, `E1.E2` is an lvalue.
436
  - Otherwise (when `E2` refers to a non-static member function),
437
+ `E1.E2` is a prvalue. \[*Note 5*: Any redundant set of parentheses
438
+ surrounding the expression is ignored
439
+ [[expr.prim.paren]]. *end note*]
440
+ - Otherwise, if `E2` designates a nested type, the expression `E1.E2` is
441
+ ill-formed.
442
+ - Otherwise, if `E2` designates a member enumerator and the type of `E2`
443
+ is `T`, the expression `E1.E2` is a prvalue of type `T` whose value is
444
+ the value of the enumerator.
445
+ - Otherwise, if `E2` designates a direct base class relationship (D, B)
446
+ and the type of `E1` is cv `T`, the expression designates the direct
447
+ base class subobject of type B of the object designated by `E1`. If
448
+ `E1` is an lvalue, then `E1.E2` is an lvalue; otherwise, `E1.E2` is an
449
+ xvalue. The type of `E1.E2` is “cv `B`”.
450
+ \[*Note 6*: This can only occur in an expression of the form
451
+ `e1.[:e2:]`. *end note*]
452
+ \[*Example 1*:
453
+ ``` cpp
454
+ struct B {
455
+ int b;
456
+ };
457
+ struct C : B {
458
+ int get() const { return b; }
459
+ };
460
+ struct D : B, C { };
461
+
462
+ constexpr int f() {
463
+ D d = {1, {}};
464
+
465
+ // b unambiguously refers to the direct base class of type B,
466
+ // not the indirect base class of type B
467
+ B& b = d.[: std::meta::bases_of(^^D, std::meta::access_context::current())[0] :];
468
+ b.b += 10;
469
+ return 10 * b.b + d.get();
470
+ }
471
+ static_assert(f() == 110);
472
+ ```
473
+
474
+ — *end example*]
475
+ - Otherwise, the program is ill-formed.
476
+
477
+ If `E2` designates a non-static member (possibly after overload
478
+ resolution), the program is ill-formed if the class of which `E2`
479
+ designates a direct member is an ambiguous base [[class.member.lookup]]
480
+ of the designating class [[class.access.base]] of `E2`.
481
+
482
+ [*Note 7*: The program is also ill-formed if the naming class is an
483
  ambiguous base of the class type of the object expression; see 
484
  [[class.access.base]]. — *end note*]
485
 
486
+ If `E2` designates a non-static member (possibly after overload
487
+ resolution) and the result of `E1` is an object whose type is not
488
+ similar [[conv.qual]] to the type of `E1`, the behavior is undefined.
489
 
490
+ [*Example 2*:
491
 
492
  ``` cpp
493
  struct A { int i; };
494
  struct B { int j; };
495
  struct D : A, B {};
 
502
 
503
  — *end example*]
504
 
505
  #### Increment and decrement <a id="expr.post.incr">[[expr.post.incr]]</a>
506
 
507
+ The value of a postfix `++` expression is the value obtained by applying
508
+ the lvalue-to-rvalue conversion [[conv.lval]] to its operand.
509
 
510
  [*Note 1*: The value obtained is a copy of the original
511
  value. — *end note*]
512
 
513
  The operand shall be a modifiable lvalue. The type of the operand shall
514
  be an arithmetic type other than cv `bool`, or a pointer to a complete
515
  object type. An operand with volatile-qualified type is deprecated; see 
516
  [[depr.volatile.type]]. The value of the operand object is modified
517
+ [[defns.access]] as if it were the operand of the prefix `++` operator
518
+ [[expr.pre.incr]]. The value computation of the `++` expression is
519
+ sequenced before the modification of the operand object. With respect to
520
+ an indeterminately-sequenced function call, the operation of postfix
521
+ `++` is a single evaluation.
522
 
523
  [*Note 2*: Therefore, a function call cannot intervene between the
524
  lvalue-to-rvalue conversion and the side effect associated with any
525
  single postfix `++` operator. — *end note*]
526
 
527
  The result is a prvalue. The type of the result is the cv-unqualified
528
+ version of the type of the operand.
 
 
 
529
 
530
  The operand of postfix `--` is decremented analogously to the postfix
531
  `++` operator.
532
 
533
  [*Note 3*: For prefix increment and decrement, see 
 
555
  such that `B` is a base class of `D`, the result is a pointer to the
556
  unique `B` subobject of the `D` object pointed to by `v`, or a null
557
  pointer value if `v` is a null pointer value. Similarly, if `T` is
558
  “reference to *cv1* `B`” and `v` has type *cv2* `D` such that `B` is a
559
  base class of `D`, the result is the unique `B` subobject of the `D`
560
+ object referred to by `v`.[^13]
561
 
562
  In both the pointer and reference cases, the program is ill-formed if
563
  `B` is an inaccessible or ambiguous base class of `D`.
564
 
565
  [*Example 1*:
 
577
  Otherwise, `v` shall be a pointer to or a glvalue of a polymorphic type
578
  [[class.virtual]].
579
 
580
  If `v` is a null pointer value, the result is a null pointer value.
581
 
582
+ If `v` has type “pointer to cv `U`” and `v` does not point to an object
583
+ whose type is similar [[conv.qual]] to `U` and that is within its
584
+ lifetime or within its period of construction or destruction
585
+ [[class.cdtor]], the behavior is undefined. If `v` is a glvalue of type
586
+ `U` and `v` does not refer to an object whose type is similar to `U` and
587
+ that is within its lifetime or within its period of construction or
588
+ destruction, the behavior is undefined.
589
+
590
  If `T` is “pointer to cv `void`”, then the result is a pointer to the
591
  most derived object pointed to by `v`. Otherwise, a runtime check is
592
  applied to see if the object pointed or referred to by `v` can be
593
  converted to the type pointed or referred to by `T`.
594
 
 
596
  check logically executes as follows:
597
 
598
  - If, in the most derived object pointed (referred) to by `v`, `v`
599
  points (refers) to a public base class subobject of a `C` object, and
600
  if only one object of type `C` is derived from the subobject pointed
601
+ (referred) to by `v`, the result points (refers) to that `C` object.
602
  - Otherwise, if `v` points (refers) to a public base class subobject of
603
  the most derived object, and the type of the most derived object has a
604
  base class, of type `C`, that is unambiguous and public, the result
605
  points (refers) to the `C` subobject of the most derived object.
606
  - Otherwise, the runtime check *fails*.
 
646
 
647
  #### Type identification <a id="expr.typeid">[[expr.typeid]]</a>
648
 
649
  The result of a `typeid` expression is an lvalue of static type `const`
650
  `std::type_info` [[type.info]] and dynamic type `const` `std::type_info`
651
+ or `const` `name` where `name` is an *implementation-defined* class
652
  publicly derived from `std::type_info` which preserves the behavior
653
+ described in  [[type.info]].[^14]
654
 
655
  The lifetime of the object referred to by the lvalue extends to the end
656
  of the program. Whether or not the destructor is called for the
657
  `std::type_info` object at the end of the program is unspecified.
658
 
659
  If the type of the *expression* or *type-id* operand is a (possibly
660
  cv-qualified) class type or a reference to (possibly cv-qualified) class
661
  type, that class shall be completely defined.
662
 
663
+ If an *expression* operand of `typeid` is a possibly-parenthesized
664
+ *unary-expression* whose *unary-operator* is `*` and whose operand
665
+ evaluates to a null pointer value [[basic.compound]], the `typeid`
666
+ expression throws an exception [[except.throw]] of a type that would
667
+ match a handler of type `std::bad_typeid` [[bad.typeid]].
668
+
669
+ [*Note 1*: In other contexts, evaluating such a *unary-expression*
670
+ results in undefined behavior [[expr.unary.op]]. — *end note*]
671
+
672
  When `typeid` is applied to a glvalue whose type is a polymorphic class
673
  type [[class.virtual]], the result refers to a `std::type_info` object
674
  representing the type of the most derived object [[intro.object]] (that
675
+ is, the dynamic type) to which the glvalue refers.
 
 
 
 
 
676
 
677
  When `typeid` is applied to an expression other than a glvalue of a
678
  polymorphic class type, the result refers to a `std::type_info` object
679
  representing the static type of the expression. Lvalue-to-rvalue
680
  [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
 
687
  `std::type_info` object representing the type of the *type-id*. If the
688
  type of the *type-id* is a reference to a possibly cv-qualified type,
689
  the result of the `typeid` expression refers to a `std::type_info`
690
  object representing the cv-unqualified referenced type.
691
 
692
+ [*Note 2*: The *type-id* cannot denote a function type with a
693
  *cv-qualifier-seq* or a *ref-qualifier* [[dcl.fct]]. — *end note*]
694
 
695
  If the type of the expression or *type-id* is a cv-qualified type, the
696
  result of the `typeid` expression refers to a `std::type_info` object
697
  representing the cv-unqualified type.
 
714
  The type `std::type_info` [[type.info]] is not predefined; if a standard
715
  library declaration [[typeinfo.syn]], [[std.modules]] of
716
  `std::type_info` does not precede [[basic.lookup.general]] a `typeid`
717
  expression, the program is ill-formed.
718
 
719
+ [*Note 3*: Subclause [[class.cdtor]] describes the behavior of `typeid`
720
  applied to an object under construction or destruction. — *end note*]
721
 
722
  #### Static cast <a id="expr.static.cast">[[expr.static.cast]]</a>
723
 
724
  The result of the expression `static_cast<T>(v)` is the result of
725
  converting the expression `v` to type `T`. If `T` is an lvalue reference
726
  type or an rvalue reference to function type, the result is an lvalue;
727
  if `T` is an rvalue reference to object type, the result is an xvalue;
728
+ otherwise, the result is a prvalue.
 
729
 
730
  An lvalue of type “*cv1* `B`”, where `B` is a class type, can be cast to
731
+ type “reference to *cv2* `D`”, where `D` is a complete class derived
732
  [[class.derived]] from `B`, if *cv2* is the same cv-qualification as, or
733
  greater cv-qualification than, *cv1*. If `B` is a virtual base class of
734
  `D` or a base class of a virtual base class of `D`, or if no valid
735
  standard conversion from “pointer to `D`” to “pointer to `B`” exists
736
  [[conv.ptr]], the program is ill-formed. An xvalue of type “*cv1* `B`”
 
761
  used as the operand of the `static_cast` for the remainder of this
762
  subclause. If `T2` is an inaccessible [[class.access]] or ambiguous
763
  [[class.member.lookup]] base class of `T1`, a program that necessitates
764
  such a cast is ill-formed.
765
 
766
+ Any expression can be explicitly converted to type cv `void`, in which
767
+ case the operand is a discarded-value expression [[expr.prop]].
768
+
769
+ [*Note 1*: Such a `static_cast` has no result as it is a prvalue of
770
+ type `void`; see  [[basic.lval]]. — *end note*]
771
+
772
+ [*Note 2*: However, if the value is in a temporary object
773
+ [[class.temporary]], the destructor for that object is not executed
774
+ until the usual time, and the value of the object is preserved for the
775
+ purpose of executing the destructor. — *end note*]
776
+
777
+ Otherwise, an expression E can be explicitly converted to a type `T` if
778
+ there is an implicit conversion sequence [[over.best.ics]] from E to
779
+ `T`, if overload resolution for a direct-initialization [[dcl.init]] of
780
+ an object or reference of type `T` from E would find at least one viable
781
  function [[over.match.viable]], or if `T` is an aggregate type
782
  [[dcl.init.aggr]] having a first element `x` and there is an implicit
783
  conversion sequence from E to the type of `x`. If `T` is a reference
784
  type, the effect is the same as performing the declaration and
785
  initialization
 
790
 
791
  for some invented temporary variable `t` [[dcl.init]] and then using the
792
  temporary variable as the result of the conversion. Otherwise, the
793
  result object is direct-initialized from E.
794
 
795
+ [*Note 3*: The conversion is ill-formed when attempting to convert an
796
  expression of class type to an inaccessible or ambiguous base
797
  class. — *end note*]
798
 
799
+ [*Note 4*: If `T` is “array of unknown bound of `U`”, this
800
  direct-initialization defines the type of the expression as
801
  `U[1]`. — *end note*]
802
 
803
+ Otherwise, the lvalue-to-rvalue [[conv.lval]], array-to-pointer
804
+ [[conv.array]], and function-to-pointer [[conv.func]] conversions are
805
+ applied to the operand, and the conversions that can be performed using
806
+ `static_cast` are listed below. No other conversion can be performed
807
+ using `static_cast`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
 
809
  A value of a scoped enumeration type [[dcl.enum]] can be explicitly
810
  converted to an integral type; the result is the same as that of
811
  converting to the enumeration’s underlying type and then to the
812
  destination type. A value of a scoped enumeration type can also be
 
859
 
860
  If no valid standard conversion from “pointer to member of `B` of type
861
  `T`” to “pointer to member of `D` of type `T`” exists [[conv.mem]], the
862
  program is ill-formed. The null member pointer value [[conv.mem]] is
863
  converted to the null member pointer value of the destination type. If
864
+ class `B` contains the original member, or is a base class of the class
865
+ containing the original member, the resulting pointer to member points
866
+ to the original member. Otherwise, the behavior is undefined.
 
867
 
868
  [*Note 6*: Although class `B` need not contain the original member, the
869
  dynamic type of the object with which indirection through the pointer to
870
  member is performed must contain the original member; see 
871
  [[expr.mptr.oper]]. — *end note*]
 
873
  A prvalue of type “pointer to *cv1* `void`” can be converted to a
874
  prvalue of type “pointer to *cv2* `T`”, where `T` is an object type and
875
  *cv2* is the same cv-qualification as, or greater cv-qualification than,
876
  *cv1*. If the original pointer value represents the address `A` of a
877
  byte in memory and `A` does not satisfy the alignment requirement of
878
+ `T`, then the resulting pointer value [[basic.compound]] is unspecified.
879
+ Otherwise, if the original pointer value points to an object *a*, and
880
+ there is an object *b* of type similar to `T` that is
881
+ pointer-interconvertible [[basic.compound]] with *a*, the result is a
882
+ pointer to *b*. Otherwise, the pointer value is unchanged by the
883
+ conversion.
884
 
885
+ [*Example 2*:
886
 
887
  ``` cpp
888
  T* p1 = new T;
889
  const T* p2 = static_cast<const T*>(static_cast<void*>(p1));
890
  bool b = p1 == p2; // b will have the value true.
 
929
  any type to the type `std::nullptr_t`. — *end note*]
930
 
931
  A value of integral type or enumeration type can be explicitly converted
932
  to a pointer. A pointer converted to an integer of sufficient size (if
933
  any such exists on the implementation) and back to the same pointer type
934
+ will have its original value [[basic.compound]]; mappings between
935
+ pointers and integers are otherwise *implementation-defined*.
936
 
937
  A function pointer can be explicitly converted to a function pointer of
938
  a different type.
939
 
940
  [*Note 4*: The effect of calling a function through a pointer to a
 
944
  Except that converting a prvalue of type “pointer to `T1`” to the type
945
  “pointer to `T2`” (where `T1` and `T2` are function types) and back to
946
  its original type yields the original pointer value, the result of such
947
  a pointer conversion is unspecified.
948
 
 
 
 
949
  An object pointer can be explicitly converted to an object pointer of a
950
+ different type.[^15]
951
 
952
  When a prvalue `v` of object pointer type is converted to the object
953
  pointer type “pointer to cv `T`”, the result is
954
  `static_cast<cv T*>(static_cast<cv~void*>(v))`.
955
 
956
+ [*Note 5*: Converting a pointer of type “pointer to `T1`” that points
957
  to an object of type `T1` to the type “pointer to `T2`” (where `T2` is
958
  an object type and the alignment requirements of `T2` are no stricter
959
  than those of `T1`) and back to its original type yields the original
960
  pointer value. — *end note*]
961
 
 
967
  yield the original pointer value.
968
 
969
  The null pointer value [[basic.compound]] is converted to the null
970
  pointer value of the destination type.
971
 
972
+ [*Note 6*: A null pointer constant of type `std::nullptr_t` cannot be
973
  converted to a pointer type, and a null pointer constant of integral
974
  type is not necessarily converted to a null pointer
975
  value. — *end note*]
976
 
977
  A prvalue of type “pointer to member of `X` of type `T1`” can be
978
  explicitly converted to a prvalue of a different type “pointer to member
979
  of `Y` of type `T2`” if `T1` and `T2` are both function types or both
980
+ object types.[^16]
981
 
982
  The null member pointer value [[conv.mem]] is converted to the null
983
  member pointer value of the destination type. The result of this
984
  conversion is unspecified, except in the following cases:
985
 
 
990
  `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
991
  the alignment requirements of `T2` are no stricter than those of `T1`)
992
  and back to its original type yields the original pointer-to-member
993
  value.
994
 
995
+ If `v` is a glvalue of type `T1`, designating an object or function *x*,
996
+ it can be cast to the type “reference to `T2`” if an expression of type
997
+ “pointer to `T1`” can be explicitly converted to the type “pointer to
998
+ `T2`” using a `reinterpret_cast`. The result is that of
999
+ `*reinterpret_cast<T2 *>(p)` where `p` is a pointer to *x* of type
1000
+ “pointer to `T1`”.
1001
+
1002
+ [*Note 7*:
1003
+
1004
+ No temporary is materialized [[conv.rval]] or created, no copy is made,
1005
+ and no constructors [[class.ctor]] or conversion functions
1006
+ [[class.conv]] are called.[^17]
1007
+
1008
+ — *end note*]
1009
 
1010
  #### Const cast <a id="expr.const.cast">[[expr.const.cast]]</a>
1011
 
1012
  The result of the expression `const_cast<T>(v)` is of type `T`. If `T`
1013
  is an lvalue reference to object type, the result is an lvalue; if `T`
1014
  is an rvalue reference to object type, the result is an xvalue;
1015
  otherwise, the result is a prvalue and the lvalue-to-rvalue
1016
  [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
1017
  [[conv.func]] standard conversions are performed on the expression `v`.
1018
+ The temporary materialization conversion [[conv.rval]] is not performed
1019
+ on `v`, other than as specified below. Conversions that can be performed
1020
+ explicitly using `const_cast` are listed below. No other conversion
1021
+ shall be performed explicitly using `const_cast`.
1022
 
1023
  [*Note 1*: Subject to the restrictions in this subclause, an expression
1024
  can be cast to its own type using a `const_cast`
1025
  operator. — *end note*]
1026
 
1027
+ For two similar object pointer or pointer to data member types `T1` and
1028
+ `T2` [[conv.qual]], a prvalue of type `T1` can be explicitly converted
1029
+ to the type `T2` using a `const_cast` if, considering the
1030
+ qualification-decompositions of both types, each P¹is the same as P²ᵢ
1031
+ for all i. If `v` is a null pointer or null member pointer, the result
1032
+ is a null pointer or null member pointer, respectively. Otherwise, the
1033
+ result points to or past the end of the same object, or points to the
1034
+ same member, respectively, as `v`.
 
 
 
 
 
 
 
 
 
 
 
1035
 
1036
  For two object types `T1` and `T2`, if a pointer to `T1` can be
1037
  explicitly converted to the type “pointer to `T2`” using a `const_cast`,
1038
  then the following conversions can also be made:
1039
 
1040
  - an lvalue of type `T1` can be explicitly converted to an lvalue of
1041
  type `T2` using the cast `const_cast<T2&>`;
1042
  - a glvalue of type `T1` can be explicitly converted to an xvalue of
1043
  type `T2` using the cast `const_cast<T2&&>`; and
1044
+ - if `T1` is a class or array type, a prvalue of type `T1` can be
1045
+ explicitly converted to an xvalue of type `T2` using the cast
1046
+ `const_cast<T2&&>`. The temporary materialization conversion is
1047
+ performed on `v`.
1048
 
1049
+ The result refers to the same object as the (possibly converted)
1050
+ operand.
 
1051
 
1052
+ [*Example 1*:
1053
+
1054
+ ``` cpp
1055
+ typedef int *A[3]; // array of 3 pointer to int
1056
+ typedef const int *const CA[3]; // array of 3 const pointer to const int
1057
+
1058
+ auto &&r2 = const_cast<A&&>(CA{}); // OK, temporary materialization conversion is performed
1059
+ ```
1060
+
1061
+ — *end example*]
1062
 
1063
  [*Note 2*:
1064
 
1065
  Depending on the type of the object, a write operation through the
1066
  pointer, lvalue or pointer to data member resulting from a `const_cast`
1067
+ that casts away a const-qualifier[^18]
1068
 
1069
  can produce undefined behavior [[dcl.type.cv]].
1070
 
1071
  — *end note*]
1072
 
 
1112
  sizeof '...' '(' identifier ')'
1113
  alignof '(' type-id ')'
1114
  noexcept-expression
1115
  new-expression
1116
  delete-expression
1117
+ reflect-expression
1118
  ```
1119
 
1120
  ``` bnf
1121
  %% Ed. note: character protrusion would misalign operators.
1122
 
 
1126
 
1127
  #### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
1128
 
1129
  The unary `*` operator performs *indirection*. Its operand shall be a
1130
  prvalue of type “pointer to `T`”, where `T` is an object or function
1131
+ type. The operator yields an lvalue of type `T`. If the operand points
1132
+ to an object or function, the result denotes that object or function;
1133
+ otherwise, the behavior is undefined except as specified in
1134
+ [[expr.typeid]].
1135
 
1136
+ [*Note 1*: Indirection through a pointer to an out-of-lifetime object
1137
+ is valid [[basic.life]]. — *end note*]
1138
+
1139
+ [*Note 2*: Indirection through a pointer to an incomplete type (other
1140
  than cv `void`) is valid. The lvalue thus obtained can be used in
1141
  limited ways (to initialize a reference, for example); this lvalue must
1142
  not be converted to a prvalue, see  [[conv.lval]]. — *end note*]
1143
 
1144
  Each of the following unary operators yields a prvalue.
1145
 
1146
  The operand of the unary `&` operator shall be an lvalue of some type
1147
+ `T`.
1148
 
1149
+ - If the operand is a *qualified-id* or *splice-expression* designating
1150
+ a non-static member `m`, other than an explicit object member
1151
+ function, `m` shall be a direct member of some class `C` that is not
1152
+ an anonymous union. The result has type “pointer to member of class
1153
+ `C` of type `T`” and designates `C::m`. \[*Note 3*: A *qualified-id*
1154
+ that names a member of a namespace-scope anonymous union is considered
1155
+ to be a class member access expression [[expr.prim.id.general]] and
1156
+ cannot be used to form a pointer to member. — *end note*]
1157
  - Otherwise, the result has type “pointer to `T`” and points to the
1158
  designated object [[intro.memory]] or function [[basic.compound]]. If
1159
+ the operand designates an explicit object member function [[dcl.fct]],
1160
+ the operand shall be a *qualified-id* or a *splice-expression*.
1161
+ \[*Note 4*: In particular, taking the address of a variable of type
1162
+ cv `T`” yields a pointer of type “pointer to cv `T`”. — *end note*]
1163
 
1164
  [*Example 1*:
1165
 
1166
  ``` cpp
1167
  struct A { int i; };
 
1173
  bool b = p2 > p1; // defined behavior, with value true
1174
  ```
1175
 
1176
  — *end example*]
1177
 
1178
+ [*Note 5*: A pointer to member formed from a `mutable` non-static data
1179
  member [[dcl.stc]] does not reflect the `mutable` specifier associated
1180
  with the non-static data member. — *end note*]
1181
 
1182
  A pointer to member is only formed when an explicit `&` is used and its
1183
+ operand is a *qualified-id* or *splice-expression* not enclosed in
1184
+ parentheses.
1185
 
1186
+ [*Note 6*: That is, the expression `&(qualified-id)`, where the
1187
  *qualified-id* is enclosed in parentheses, does not form an expression
1188
  of type “pointer to member”. Neither does `qualified-id`, because there
1189
  is no implicit conversion from a *qualified-id* for a non-static member
1190
  function to the type “pointer to member function” as there is from an
1191
  lvalue of function type to the type “pointer to function” [[conv.func]].
 
1195
  If `&` is applied to an lvalue of incomplete class type and the complete
1196
  type declares `operator&()`, it is unspecified whether the operator has
1197
  the built-in meaning or the operator function is called. The operand of
1198
  `&` shall not be a bit-field.
1199
 
1200
+ [*Note 7*: The address of an overload set [[over]] can be taken only in
1201
  a context that uniquely determines which function is referred to (see 
1202
  [[over.over]]). Since the context can affect whether the operand is a
1203
  static or non-static member function, the context can also affect
1204
  whether the expression has type “pointer to function” or “pointer to
1205
  member function”. — *end note*]
1206
 
1207
+ The operand of the unary `+` operator shall be a prvalue of arithmetic,
1208
+ unscoped enumeration, or pointer type and the result is the value of the
1209
  argument. Integral promotion is performed on integral or enumeration
1210
  operands. The type of the result is the type of the promoted operand.
1211
 
1212
+ The operand of the unary `-` operator shall be a prvalue of arithmetic
1213
+ or unscoped enumeration type and the result is the negative of its
1214
+ operand. Integral promotion is performed on integral or enumeration
1215
+ operands. The negative of an unsigned quantity is computed by
1216
+ subtracting its value from 2ⁿ, where n is the number of bits in the
1217
+ promoted operand. The type of the result is the type of the promoted
1218
+ operand.
1219
 
1220
+ [*Note 8*: The result is the two’s complement of the operand (where
1221
  operand and result are considered as unsigned). — *end note*]
1222
 
1223
  The operand of the logical negation operator `!` is contextually
1224
  converted to `bool` [[conv]]; its value is `true` if the converted
1225
  operand is `false` and `false` otherwise. The type of the result is
1226
  `bool`.
1227
 
1228
+ The operand of the `~` operator shall be a prvalue of integral or
1229
+ unscoped enumeration type. Integral promotions are performed. The type
1230
+ of the result is the type of the promoted operand. Given the
1231
+ coefficients `xᵢ` of the base-2 representation [[basic.fundamental]] of
1232
+ the promoted operand `x`, the coefficient `rᵢ` of the base-2
1233
+ representation of the result `r` is 1 if `xᵢ` is 0, and 0 otherwise.
1234
 
1235
+ [*Note 9*: The result is the ones’ complement of the operand (where
1236
  operand and result are considered as unsigned). — *end note*]
1237
 
1238
  There is an ambiguity in the grammar when `~` is followed by a
1239
+ *type-name* or *computed-type-specifier*. The ambiguity is resolved by
1240
  treating `~` as the operator rather than as the start of an
1241
  *unqualified-id* naming a destructor.
1242
 
1243
+ [*Note 10*: Because the grammar does not permit an operator to follow
1244
  the `.`, `->`, or `::` tokens, a `~` followed by a *type-name* or
1245
+ *computed-type-specifier* in a member access expression or
1246
+ *qualified-id* is unambiguously parsed as a destructor
1247
+ name. — *end note*]
1248
 
1249
  #### Increment and decrement <a id="expr.pre.incr">[[expr.pre.incr]]</a>
1250
 
1251
+ The operand of prefix `++` or `--` shall not be of type cv `bool`. An
1252
+ operand with volatile-qualified type is deprecated; see 
1253
+ [[depr.volatile.type]]. The expression `++x` is otherwise equivalent to
1254
+ `x+=1` and the expression `--x` is otherwise equivalent to `x-=1`
1255
+ [[expr.assign]].
 
 
1256
 
1257
+ [*Note 1*: For postfix increment and decrement, see 
 
 
 
 
 
 
 
1258
  [[expr.post.incr]]. — *end note*]
1259
 
1260
  #### Await <a id="expr.await">[[expr.await]]</a>
1261
 
1262
  The `co_await` expression is used to suspend evaluation of a coroutine
1263
  [[dcl.fct.def.coroutine]] while awaiting completion of the computation
1264
+ represented by the operand expression. Suspending the evaluation of a
1265
+ coroutine transfers control to its caller or resumer.
1266
 
1267
  ``` bnf
1268
  await-expression:
1269
+ co_await cast-expression
1270
  ```
1271
 
1272
+ An *await-expression* shall appear only as a potentially-evaluated
1273
+ expression within the *compound-statement* of a *function-body* or
1274
+ *lambda-expression*, in either case outside of a *handler*
1275
+ [[except.pre]]. In a *declaration-statement* or in the
1276
  *simple-declaration* (if any) of an *init-statement*, an
1277
  *await-expression* shall appear only in an *initializer* of that
1278
  *declaration-statement* or *simple-declaration*. An *await-expression*
1279
  shall not appear in a default argument [[dcl.fct.default]]. An
1280
  *await-expression* shall not appear in the initializer of a block
1281
+ variable with static or thread storage duration. An *await-expression*
1282
+ shall not be a potentially-evaluated subexpression of the predicate of a
1283
+ contract assertion [[basic.contract]]. A context within a function where
1284
+ an *await-expression* can appear is called a *suspension context* of the
1285
+ function.
1286
 
1287
  Evaluation of an *await-expression* involves the following auxiliary
1288
  types, expressions, and objects:
1289
 
1290
  - *p* is an lvalue naming the promise object [[dcl.fct.def.coroutine]]
 
1404
 
1405
  [*Note 1*:
1406
 
1407
  In particular, the values of `sizeof(bool)`, `sizeof(char16_t)`,
1408
  `sizeof(char32_t)`, and `sizeof(wchar_t)` are
1409
+ implementation-defined.[^19]
1410
 
1411
  — *end note*]
1412
 
1413
  [*Note 2*: See  [[intro.memory]] for the definition of byte and 
1414
  [[term.object.representation]] for the definition of object
 
1417
  When applied to a reference type, the result is the size of the
1418
  referenced type. When applied to a class, the result is the number of
1419
  bytes in an object of that class including any padding required for
1420
  placing objects of that type in an array. The result of applying
1421
  `sizeof` to a potentially-overlapping subobject is the size of the type,
1422
+ not the size of the subobject.[^20]
1423
 
1424
  When applied to an array, the result is the total number of bytes in the
1425
  array. This implies that the size of an array of n elements is n times
1426
  the size of an element.
1427
 
1428
  The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
1429
  function-to-pointer [[conv.func]] standard conversions are not applied
1430
  to the operand of `sizeof`. If the operand is a prvalue, the temporary
1431
  materialization conversion [[conv.rval]] is applied.
1432
 
1433
+ The *identifier* in a `sizeof...` expression shall name a pack. The
1434
  `sizeof...` operator yields the number of elements in the pack
1435
  [[temp.variadic]]. A `sizeof...` expression is a pack expansion
1436
  [[temp.variadic]].
1437
 
1438
  [*Example 1*:
1439
 
1440
  ``` cpp
1441
  template<class... Types>
1442
  struct count {
1443
+ static constexpr std::size_t value = sizeof...(Types);
1444
  };
1445
  ```
1446
 
1447
  — *end example*]
1448
 
1449
  The result of `sizeof` and `sizeof...` is a prvalue of type
1450
  `std::size_t`.
1451
 
1452
  [*Note 3*: A `sizeof` expression is an integral constant expression
1453
+ [[expr.const]]. The *typedef-name* `std::size_t` is declared in the
1454
+ standard header `<cstddef>`
1455
+ [[cstddef.syn]], [[support.types.layout]]. — *end note*]
1456
 
1457
  #### Alignof <a id="expr.alignof">[[expr.alignof]]</a>
1458
 
1459
  An `alignof` expression yields the alignment requirement of its operand
1460
  type. The operand shall be a *type-id* representing a complete object
1461
  type, or an array thereof, or a reference to one of those types.
1462
 
1463
  The result is a prvalue of type `std::size_t`.
1464
 
1465
  [*Note 1*: An `alignof` expression is an integral constant expression
1466
+ [[expr.const]]. The *typedef-name* `std::size_t` is declared in the
1467
+ standard header `<cstddef>`
1468
+ [[cstddef.syn]], [[support.types.layout]]. — *end note*]
1469
 
1470
  When `alignof` is applied to a reference type, the result is the
1471
  alignment of the referenced type. When `alignof` is applied to an array
1472
  type, the result is the alignment of the element type.
1473
 
1474
  #### `noexcept` operator <a id="expr.unary.noexcept">[[expr.unary.noexcept]]</a>
1475
 
 
 
 
 
1476
  ``` bnf
1477
  noexcept-expression:
1478
  noexcept '(' expression ')'
1479
  ```
1480
 
1481
+ The operand of the `noexcept` operator is an unevaluated operand
1482
+ [[term.unevaluated.operand]]. If the operand is a prvalue, the temporary
1483
+ materialization conversion [[conv.rval]] is applied.
1484
+
1485
+ The result of the `noexcept` operator is a prvalue of type `bool`. The
1486
+ result is `false` if the full-expression of the operand is
1487
+ potentially-throwing [[except.spec]], and `true` otherwise.
1488
 
1489
  [*Note 1*: A *noexcept-expression* is an integral constant expression
1490
  [[expr.const]]. — *end note*]
1491
 
 
 
 
1492
  #### New <a id="expr.new">[[expr.new]]</a>
1493
 
1494
+ The *new-expression* attempts to create an object of the *type-id* or
1495
+ *new-type-id* [[dcl.name]] to which it is applied. The type of that
1496
  object is the *allocated type*. This type shall be a complete object
1497
  type [[term.incomplete.type]], but not an abstract class type
1498
  [[class.abstract]] or array thereof [[intro.object]].
1499
 
1500
  [*Note 1*: Because references are not objects, references cannot be
 
1536
  new-initializer:
1537
  '(' expression-listₒₚₜ ')'
1538
  braced-init-list
1539
  ```
1540
 
1541
+ If a placeholder type [[dcl.spec.auto]] or a placeholder for a deduced
1542
+ class type [[dcl.type.class.deduct]] appears in the *type-specifier-seq*
1543
+ of a *new-type-id* or *type-id* of a *new-expression*, the allocated
1544
+ type is deduced as follows: Let *init* be the *new-initializer*, if any,
1545
+ and `T` be the *new-type-id* or *type-id* of the *new-expression*, then
1546
+ the allocated type is the type deduced for the variable `x` in the
1547
+ invented declaration [[dcl.spec.auto]]:
1548
 
1549
  ``` cpp
1550
  T x init ;
1551
  ```
1552
 
 
1618
  its value shall be greater than zero.
1619
 
1620
  [*Example 4*: Given the definition `int n = 42`, `new float[n][5]` is
1621
  well-formed (because `n` is the *expression* of a
1622
  *noptr-new-declarator*), but `new float[5][n]` is ill-formed (because
1623
+ `n` is not a constant expression). Furthermore, `new float[0]` is
1624
+ well-formed (because `0` is the *expression* of a
1625
+ *noptr-new-declarator*, where a value of zero results in the allocation
1626
+ of an array with no elements), but `new float[n][0]` is ill-formed
1627
+ (because `0` is the *constant-expression* of a *noptr-new-declarator*,
1628
+ where only values greater than zero are allowed). — *end example*]
1629
 
1630
  If the *type-id* or *new-type-id* denotes an array type of unknown bound
1631
  [[dcl.array]], the *new-initializer* shall not be omitted; the allocated
1632
  object is an array with `n` elements, where `n` is determined from the
1633
  number of initial elements supplied in the *new-initializer*
1634
  [[dcl.init.aggr]], [[dcl.init.string]].
1635
 
1636
  If the *expression* in a *noptr-new-declarator* is present, it is
1637
+ implicitly converted to `std::size_t`. The value of the *expression* is
1638
+ invalid if
1639
 
1640
  - the expression is of non-class type and its value before converting to
1641
  `std::size_t` is less than zero;
1642
  - the expression is of class type and its value before application of
1643
+ the second standard conversion [[over.ics.user]][^21] is less than
1644
  zero;
1645
  - its value is such that the size of the allocated object would exceed
1646
  the *implementation-defined* limit [[implimits]]; or
1647
  - the *new-initializer* is a *braced-init-list* and the number of array
1648
  elements for which initializers are provided (including the
1649
  terminating `'\0'` in a *string-literal* [[lex.string]]) exceeds the
1650
  number of elements to initialize.
1651
 
1652
+ If the value of the *expression* is invalid after converting to
1653
+ `std::size_t`:
1654
 
1655
  - if the *expression* is a potentially-evaluated core constant
1656
  expression, the program is ill-formed;
1657
  - otherwise, an allocation function is not called; instead
1658
  - if the allocation function that would have been called has a
 
1664
  `std::bad_array_new_length` [[new.badlength]].
1665
 
1666
  When the value of the *expression* is zero, the allocation function is
1667
  called to allocate an array with no elements.
1668
 
1669
+ If the allocated type is an array, the *new-initializer* is a
1670
+ *braced-init-list*, and the *expression* is potentially-evaluated and
1671
+ not a core constant expression, the semantic constraints of
1672
+ copy-initializing a hypothetical element of the array from an empty
1673
+ initializer list are checked [[dcl.init.list]].
1674
+
1675
+ [*Note 5*: The array can contain more elements than there are elements
1676
+ in the *braced-init-list*, requiring initialization of the remainder of
1677
+ the array elements from an empty initializer list. — *end note*]
1678
+
1679
  Objects created by a *new-expression* have dynamic storage duration
1680
  [[basic.stc.dynamic]].
1681
 
1682
+ [*Note 6*: The lifetime of such an object is not necessarily
1683
  restricted to the scope in which it is created. — *end note*]
1684
 
1685
  When the allocated type is “array of `N` `T`” (that is, the
1686
  *noptr-new-declarator* syntax is used or the *new-type-id* or *type-id*
1687
  denotes an array type), the *new-expression* yields a prvalue of type
1688
  “pointer to `T`” that points to the initial element (if any) of the
1689
  array. Otherwise, let `T` be the allocated type; the *new-expression* is
1690
  a prvalue of type “pointer to T” that points to the object created.
1691
 
1692
+ [*Note 7*: Both `new int` and `new int[10]` have type `int*` and the
1693
  type of `new int[i][10]` is `int (*)[10]`. — *end note*]
1694
 
1695
  A *new-expression* may obtain storage for the object by calling an
1696
  allocation function [[basic.stc.dynamic.allocation]]. If the
1697
  *new-expression* terminates by throwing an exception, it may release
 
1700
  type, the allocation function’s name is `operator new` and the
1701
  deallocation function’s name is `operator delete`. If the allocated type
1702
  is an array type, the allocation function’s name is `operator new[]` and
1703
  the deallocation function’s name is `operator delete[]`.
1704
 
1705
+ [*Note 8*: An implementation is expected to provide default definitions
1706
  for the global allocation functions
1707
  [[basic.stc.dynamic]], [[new.delete.single]], [[new.delete.array]]. A
1708
  C++ program can provide alternative definitions of these functions
1709
  [[replacement.functions]] and/or class-specific versions [[class.free]].
1710
  The set of allocation and deallocation functions that can be called by a
 
1721
  An implementation is allowed to omit a call to a replaceable global
1722
  allocation function [[new.delete.single]], [[new.delete.array]]. When it
1723
  does so, the storage is instead provided by the implementation or
1724
  provided by extending the allocation of another *new-expression*.
1725
 
1726
+ During an evaluation of a constant expression, a call to a replaceable
1727
+ allocation function is always omitted [[expr.const]].
 
 
 
 
1728
 
1729
  The implementation may extend the allocation of a *new-expression* `e1`
1730
  to provide storage for a *new-expression* `e2` if the following would be
1731
  true were the allocation not extended:
1732
 
 
1865
  value of the *new-expression* shall be null.
1866
 
1867
  [*Note 11*: When the allocation function returns a value other than
1868
  null, it must be a pointer to a block of storage in which space for the
1869
  object has been reserved. The block of storage is assumed to be
1870
+ appropriately aligned [[basic.align]] and of the requested size. The
1871
+ address of the created object will not necessarily be the same as that
1872
+ of the block if the object is an array. — *end note*]
1873
 
1874
  A *new-expression* that creates an object of type `T` initializes that
1875
  object as follows:
1876
 
1877
  - If the *new-initializer* is omitted, the object is default-initialized
 
1883
  The invocation of the allocation function is sequenced before the
1884
  evaluations of expressions in the *new-initializer*. Initialization of
1885
  the allocated object is sequenced before the value computation of the
1886
  *new-expression*.
1887
 
1888
+ If the *new-expression* creates an array of objects of class type, the
1889
+ destructor is potentially invoked [[class.dtor]].
 
 
 
 
1890
 
1891
+ If any part of the object initialization described above[^22]
1892
 
1893
  terminates by throwing an exception and a suitable deallocation function
1894
  can be found, the deallocation function is called to free the memory in
1895
  which the object was being constructed, after which the exception
1896
  continues to propagate in the context of the *new-expression*. If no
 
1915
  otherwise, no deallocation function will be called. If the lookup finds
1916
  a usual deallocation function and that function, considered as a
1917
  placement deallocation function, would have been selected as a match for
1918
  the allocation function, the program is ill-formed. For a non-placement
1919
  allocation function, the normal deallocation function lookup is used to
1920
+ find the matching deallocation function [[expr.delete]]. In any case,
1921
+ the matching deallocation function (if any) shall be non-deleted and
1922
+ accessible from the point where the *new-expression* appears.
1923
 
1924
  [*Example 7*:
1925
 
1926
  ``` cpp
1927
  struct S {
 
1960
  ```
1961
 
1962
  The first alternative is a *single-object delete expression*, and the
1963
  second is an *array delete expression*. Whenever the `delete` keyword is
1964
  immediately followed by empty square brackets, it shall be interpreted
1965
+ as the second alternative.[^23]
1966
 
1967
+ If the operand is of class type, it is contextually implicitly converted
1968
+ [[conv]] to a pointer to object type and the converted operand is used
1969
+ in place of the original operand for the remainder of this subclause.
1970
+ Otherwise, it shall be a prvalue of pointer to object type. The
1971
+ *delete-expression* has type `void`.
1972
 
1973
+ In a single-object delete expression, the value of the operand of
1974
+ `delete` may be a null pointer value, a pointer value that resulted from
1975
+ a previous non-array *new-expression*, or a pointer to a base class
1976
+ subobject of an object created by such a *new-expression*. If not, the
1977
+ behavior is undefined. In an array delete expression, the value of the
1978
+ operand of `delete` may be a null pointer value or a pointer value that
1979
+ resulted from a previous array *new-expression* whose allocation
1980
+ function was not a non-allocating form [[new.delete.placement]].[^24]
 
 
 
 
 
 
1981
 
1982
  If not, the behavior is undefined.
1983
 
1984
  [*Note 1*: This means that the syntax of the *delete-expression* must
1985
  match the type of the object allocated by `new`, not the syntax of the
 
1997
  object to be deleted and the static type shall have a virtual destructor
1998
  or the behavior is undefined. In an array delete expression, if the
1999
  dynamic type of the object to be deleted is not similar to its static
2000
  type, the behavior is undefined.
2001
 
 
 
 
2002
  If the object being deleted has incomplete class type at the point of
2003
+ deletion, the program is ill-formed.
 
2004
 
2005
  If the value of the operand of the *delete-expression* is not a null
2006
  pointer value and the selected deallocation function (see below) is not
2007
+ a destroying operator delete, evaluating the *delete-expression* invokes
2008
+ the destructor (if any) for the object or the elements of the array
2009
+ being deleted. The destructor shall be accessible from the point where
2010
+ the *delete-expression* appears. In the case of an array, the elements
2011
+ are destroyed in order of decreasing address (that is, in reverse order
2012
+ of the completion of their constructor; see  [[class.base.init]]).
2013
 
2014
  If the value of the operand of the *delete-expression* is not a null
2015
  pointer value, then:
2016
 
2017
  - If the allocation call for the *new-expression* for the object to be
 
2068
 
2069
  [*Note 5*: If only a placement deallocation function is found in a
2070
  class, the program is ill-formed because the lookup set is empty
2071
  [[basic.lookup]]. — *end note*]
2072
 
2073
+ The deallocation function to be called is selected as follows:
 
2074
 
2075
  - If any of the deallocation functions is a destroying operator delete,
2076
  all deallocation functions that are not destroying operator deletes
2077
  are eliminated from further consideration.
2078
  - If the type has new-extended alignment, a function with a parameter of
 
2088
  or a (possibly multidimensional) array thereof, the function with a
2089
  parameter of type `std::size_t` is selected.
2090
  - Otherwise, it is unspecified whether a deallocation function with a
2091
  parameter of type `std::size_t` is selected.
2092
 
2093
+ Unless the deallocation function is selected at the point of definition
2094
+ of the dynamic type’s virtual destructor, the selected deallocation
2095
+ function shall be accessible from the point where the
2096
+ *delete-expression* appears.
2097
+
2098
  For a single-object delete expression, the deleted object is the object
2099
  A pointed to by the operand if the static type of A does not have a
2100
  virtual destructor, and the most-derived object of A otherwise.
2101
 
2102
  [*Note 6*: If the deallocation function is not a destroying operator
 
2127
  function, and either the first argument was not the result of a prior
2128
  call to a replaceable allocation function or the second or third
2129
  argument was not the corresponding argument in said call, the behavior
2130
  is undefined [[new.delete.single]], [[new.delete.array]]. — *end note*]
2131
 
2132
+ #### The reflection operator <a id="expr.reflect">[[expr.reflect]]</a>
2133
+
2134
+ ``` bnf
2135
+ reflect-expression:
2136
+ '^^' '::'
2137
+ '^^' reflection-name
2138
+ '^^' type-id
2139
+ '^^' id-expression
2140
+ ```
2141
+
2142
+ ``` bnf
2143
+ reflection-name:
2144
+ nested-name-specifierₒₚₜ identifier
2145
+ nested-name-specifier template identifier
2146
+ ```
2147
+
2148
+ The unary `^^` operator, called the *reflection operator*, yields a
2149
+ prvalue of type `std::meta::info` [[basic.fundamental]].
2150
+
2151
+ [*Note 1*: This document places no restriction on representing, by
2152
+ reflections, constructs not described by this document or using the
2153
+ names of such constructs as operands of
2154
+ *reflect-expression*s. — *end note*]
2155
+
2156
+ The component names of a *reflection-name* are those of its
2157
+ *nested-name-specifier* (if any) and its *identifier*. The terminal name
2158
+ of a *reflection-name* of the form *nested-name-specifier* `template`
2159
+ *identifier* shall denote a template.
2160
+
2161
+ A *reflect-expression* is parsed as the longest possible sequence of
2162
+ tokens that could syntactically form a *reflect-expression*. An
2163
+ unparenthesized *reflect-expression* that represents a template shall
2164
+ not be followed by `<`.
2165
+
2166
+ [*Example 1*:
2167
+
2168
+ ``` cpp
2169
+ static_assert(std::meta::is_type(^^int())); // ^^ applies to the type-id int()
2170
+
2171
+ template<bool> struct X {};
2172
+ consteval bool operator<(std::meta::info, X<false>) { return false; }
2173
+ consteval void g(std::meta::info r, X<false> xv) {
2174
+ r == ^^int && true; // error: ^^ applies to the type-id int&&
2175
+ r == ^^int & true; // error: ^^ applies to the type-id int&
2176
+ r == (^^int) && true; // OK
2177
+ r == ^^int &&&& true; // error: int &&&& is not a valid type-id
2178
+ ^^X < xv; // error: reflect-expression that represents a template is followed by <
2179
+ (^^X) < xv; // OK
2180
+ ^^X<true> < xv; // OK
2181
+ }
2182
+ ```
2183
+
2184
+ — *end example*]
2185
+
2186
+ A *reflect-expression* of the form `^^ ::` represents the global
2187
+ namespace.
2188
+
2189
+ If a *reflect-expression* R matches the form `^^ reflection-name`, it is
2190
+ interpreted as such; the *identifier* is looked up and the
2191
+ representation of R is determined as follows:
2192
+
2193
+ - If lookup finds a declaration that replaced a *using-declarator*
2194
+ during a single search [[basic.lookup.general]], [[namespace.udecl]],
2195
+ R is ill-formed.
2196
+ \[*Example 2*:
2197
+ ``` cpp
2198
+ struct A { struct S {}; };
2199
+ struct B : A { using A::S; };
2200
+ constexpr std::meta::info r1 = ^^B::S; // error: A::S found through using-declarator
2201
+
2202
+ struct C : virtual B { struct S {}; };
2203
+ struct D : virtual B, C {};
2204
+ D::S s; // OK, names C::S per [class.member.lookup]
2205
+ constexpr std::meta::info r2 = ^^D::S; // OK, result C::S not found through using-declarator
2206
+ ```
2207
+
2208
+ — *end example*]
2209
+ - Otherwise, if lookup finds a namespace alias [[namespace.alias]], R
2210
+ represents that namespace alias.
2211
+ - Otherwise, if lookup finds a namespace [[basic.namespace]], R
2212
+ represents that namespace.
2213
+ - Otherwise, if lookup finds a concept [[temp.concept]], R represents
2214
+ the denoted concept.
2215
+ - Otherwise, if lookup finds a template [[temp.names]], the
2216
+ representation of R is determined as follows:
2217
+ - If lookup finds an injected-class-name [[class.pre]], then:
2218
+ - If the *reflection-name* is of the form
2219
+ `nested-name-specifier template identifier`, then R represents the
2220
+ class template named by the injected-class-name.
2221
+ - Otherwise, the injected-class-name shall be unambiguous when
2222
+ considered as a *type-name* and R represents the class template
2223
+ specialization so named.
2224
+ - Otherwise, if lookup finds an overload set, that overload set shall
2225
+ contain only declarations of a unique function template F; R
2226
+ represents F.
2227
+ - Otherwise, if lookup finds a class template, variable template, or
2228
+ alias template, R represents that template. \[*Note 2*: Lookup never
2229
+ finds a partial or explicit specialization. — *end note*]
2230
+ - Otherwise, if lookup finds a type alias A, R represents the underlying
2231
+ entity of A if A was introduced by the declaration of a template
2232
+ parameter; otherwise, R represents A.
2233
+ - Otherwise, if lookup finds a class or an enumeration, R represents the
2234
+ denoted type.
2235
+ - Otherwise, if lookup finds a class member of an anonymous union
2236
+ [[class.union.anon]], R represents that class member.
2237
+ - Otherwise, the *reflection-name* shall be an *id-expression* `I` and R
2238
+ is `^^ I` (see below).
2239
+
2240
+ A *reflect-expression* R of the form `^^ type-id` represents an entity
2241
+ determined as follows:
2242
+
2243
+ - If the *type-id* designates a placeholder type
2244
+ [[dcl.spec.auto.general]], R is ill-formed.
2245
+ - Otherwise, if the *type-id* names a type alias that is a
2246
+ specialization of an alias template [[temp.alias]], R represents that
2247
+ type alias.
2248
+ - Otherwise, R represents the type denoted by the *type-id*.
2249
+
2250
+ A *reflect-expression* R of the form `^^ id-expression` represents an
2251
+ entity determined as follows:
2252
+
2253
+ - If the *id-expression* denotes
2254
+ - a variable declared by an *init-capture*
2255
+ [[expr.prim.lambda.capture]],
2256
+ - a function-local predefined variable [[dcl.fct.def.general]],
2257
+ - a local parameter introduced by a *requires-expression*
2258
+ [[expr.prim.req]], or
2259
+ - a local entity E [[basic.pre]] for which a lambda scope intervenes
2260
+ between the point at which E was introduced and R,
2261
+
2262
+ then R is ill-formed.
2263
+ - Otherwise, if the *id-expression* denotes an overload set S, overload
2264
+ resolution for the expression `&S` with no target shall select a
2265
+ unique function [[over.over]]; R represents that function.
2266
+ - Otherwise, if the *id-expression* denotes a variable, structured
2267
+ binding, enumerator, or non-static data member, R represents that
2268
+ entity.
2269
+ - Otherwise, R is ill-formed. \[*Note 3*: This includes
2270
+ *unqualified-id*s that name a constant template parameter and
2271
+ *pack-index-expression*s. — *end note*]
2272
+
2273
+ The *id-expression* of a *reflect-expression* is an unevaluated operand
2274
+ [[expr.context]].
2275
+
2276
+ [*Example 3*:
2277
+
2278
+ ``` cpp
2279
+ template<typename T> void fn() requires (^^T != ^^int);
2280
+ template<typename T> void fn() requires (^^T == ^^int);
2281
+ template<typename T> void fn() requires (sizeof(T) == sizeof(int));
2282
+
2283
+ constexpr std::meta::info a = ^^fn<char>; // OK
2284
+ constexpr std::meta::info b = ^^fn<int>; // error: ambiguous
2285
+
2286
+ constexpr std::meta::info c = ^^std::vector; // OK
2287
+
2288
+ template<typename T>
2289
+ struct S {
2290
+ static constexpr std::meta::info r = ^^T;
2291
+ using type = T;
2292
+ };
2293
+ static_assert(S<int>::r == ^^int);
2294
+ static_assert(^^S<int>::type != ^^int);
2295
+
2296
+ typedef struct X {} Y;
2297
+ typedef struct Z {} Z;
2298
+ constexpr std::meta::info e = ^^Y; // OK, represents the type alias Y
2299
+ constexpr std::meta::info f = ^^Z; // OK, represents the type alias Z, not the type[basic.lookup.general]
2300
+ ```
2301
+
2302
+ — *end example*]
2303
 
2304
  ### Explicit type conversion (cast notation) <a id="expr.cast">[[expr.cast]]</a>
2305
 
2306
  The result of the expression `(T)` *cast-expression* is of type `T`. The
2307
  result is an lvalue if `T` is an lvalue reference type or an rvalue
 
2351
  of a derived class type, respectively.
2352
 
2353
  If a conversion can be interpreted in more than one of the ways listed
2354
  above, the interpretation that appears first in the list is used, even
2355
  if a cast resulting from that interpretation is ill-formed. If a
2356
+ `static_cast` followed by a `const_cast` is used and the conversion can
2357
+ be interpreted in more than one way as such, the conversion is
2358
+ ill-formed.
2359
 
2360
  [*Example 1*:
2361
 
2362
  ``` cpp
2363
  struct A { };
 
2365
  struct I2 : A { };
2366
  struct D : I1, I2 { };
2367
  A* foo( D* p ) {
2368
  return (A*)( p ); // ill-formed static_cast interpretation
2369
  }
2370
+
2371
+ int*** ptr = 0;
2372
+ auto t = (int const*const*const*)ptr; // OK, const_cast interpretation
2373
+
2374
+ struct S {
2375
+ operator const int*();
2376
+ operator volatile int*();
2377
+ };
2378
+ int *p = (int*)S(); // error: two possible interpretations using static_cast followed by const_cast
2379
  ```
2380
 
2381
  — *end example*]
2382
 
2383
  The operand of a cast using the cast notation can be a prvalue of type
 
2387
  incomplete, it is unspecified whether the `static_cast` or the
2388
  `reinterpret_cast` interpretation is used, even if there is an
2389
  inheritance relationship between the two classes.
2390
 
2391
  [*Note 2*: For example, if the classes were defined later in the
2392
+ translation unit, a multi-pass compiler could validly interpret a cast
2393
+ between pointers to the classes as if the class types were complete at
2394
+ the point of the cast. — *end note*]
2395
 
2396
  ### Pointer-to-member operators <a id="expr.mptr.oper">[[expr.mptr.oper]]</a>
2397
 
2398
  The pointer-to-member operators `->*` and `.*` group left-to-right.
2399
 
 
2402
  cast-expression
2403
  pm-expression '.*' cast-expression
2404
  pm-expression '->*' cast-expression
2405
  ```
2406
 
2407
+ The binary operator `.*` binds its second operand, which shall be a
2408
+ prvalue of type “pointer to member of `T`” to its first operand, which
2409
+ shall be a glvalue of class `T` or of a class of which `T` is an
2410
+ unambiguous and accessible base class. The result is an object or a
2411
+ function of the type specified by the second operand.
2412
 
2413
+ The binary operator `->*` binds its second operand, which shall be a
2414
+ prvalue of type “pointer to member of `T`” to its first operand, which
2415
+ shall be of type “pointer to `U`” where `U` is either `T` or a class of
2416
+ which `T` is an unambiguous and accessible base class. The expression
2417
+ `E1->*E2` is converted into the equivalent form `(*(E1)).*E2`.
2418
 
2419
  Abbreviating *pm-expression*`.*`*cast-expression* as `E1.*E2`, `E1` is
2420
  called the *object expression*. If the result of `E1` is an object whose
2421
  type is not similar to the type of `E1`, or whose most derived object
2422
  does not contain the member to which `E2` refers, the behavior is
 
2492
 
2493
  The binary `*` operator indicates multiplication.
2494
 
2495
  The binary `/` operator yields the quotient, and the binary `%` operator
2496
  yields the remainder from the division of the first expression by the
2497
+ second. If the second operand of `/` or `%` is zero, the behavior is
2498
+ undefined. For integral operands, the `/` operator yields the algebraic
2499
+ quotient with any fractional part discarded;[^25]
2500
 
2501
  if the quotient `a/b` is representable in the type of the result,
2502
  `(a/b)*b + a%b` is equal to `a`; otherwise, the behavior of both `a/b`
2503
  and `a%b` is undefined.
2504
 
2505
  ### Additive operators <a id="expr.add">[[expr.add]]</a>
2506
 
2507
+ The additive operators `+` and `-` group left-to-right. Each operand
2508
+ shall be a prvalue. If both operands have arithmetic or unscoped
2509
+ enumeration type, the usual arithmetic conversions [[expr.arith.conv]]
2510
+ are performed. Otherwise, if one operand has arithmetic or unscoped
2511
+ enumeration type, integral promotion is applied [[conv.prom]] to that
2512
+ operand. A converted or promoted operand is used in place of the
2513
+ corresponding original operand for the remainder of this section.
2514
 
2515
  ``` bnf
2516
  additive-expression:
2517
  multiplicative-expression
2518
  additive-expression '+' multiplicative-expression
2519
  additive-expression '-' multiplicative-expression
2520
  ```
2521
 
2522
+ For addition, either both operands shall have arithmetic type, or one
2523
+ operand shall be a pointer to a completely-defined object type and the
2524
+ other shall have integral type.
 
2525
 
2526
  For subtraction, one of the following shall hold:
2527
 
2528
+ - both operands have arithmetic type; or
2529
  - both operands are pointers to cv-qualified or cv-unqualified versions
2530
  of the same completely-defined object type; or
2531
  - the left operand is a pointer to a completely-defined object type and
2532
+ the right operand has integral type.
2533
 
2534
  The result of the binary `+` operator is the sum of the operands. The
2535
  result of the binary `-` operator is the difference resulting from the
2536
  subtraction of the second operand from the first.
2537
 
2538
  When an expression `J` that has integral type is added to or subtracted
2539
  from an expression `P` of pointer type, the result has the type of `P`.
2540
 
2541
  - If `P` evaluates to a null pointer value and `J` evaluates to 0, the
2542
  result is a null pointer value.
2543
+ - Otherwise, if `P` points to a (possibly-hypothetical) array element i
2544
+ of an array object `x` with n elements [[dcl.array]],[^26] the
2545
+ expressions `P + J` and `J + P` (where `J` has the value j) point to
2546
+ the (possibly-hypothetical) array element i + j of `x` if
2547
+ 0 ≤ i + j ≤ n and the expression `P - J` points to the
2548
+ (possibly-hypothetical) array element i - j of `x` if 0 ≤ i - j ≤ n.
2549
  - Otherwise, the behavior is undefined.
2550
 
2551
  [*Note 1*: Adding a value other than 0 or 1 to a pointer to a base
2552
  class subobject, a member subobject, or a complete object results in
2553
  undefined behavior. — *end note*]
2554
 
2555
  When two pointer expressions `P` and `Q` are subtracted, the type of the
2556
  result is an *implementation-defined* signed integral type; this type
2557
+ shall be the same type that is named by `std::ptrdiff_t` in the
2558
  `<cstddef>` header [[support.types.layout]].
2559
 
2560
  - If `P` and `Q` both evaluate to null pointer values, the result is 0.
2561
  - Otherwise, if `P` and `Q` point to, respectively, array elements i and
2562
  j of the same array object `x`, the expression `P - Q` has the value
2563
+ i - j. \[*Note 2*: If the value i - j is not in the range of
2564
+ representable values of type `std::ptrdiff_t`, the behavior is
2565
+ undefined [[expr.pre]]. *end note*]
2566
+ - Otherwise, the behavior is undefined.
2567
 
2568
  For addition or subtraction, if the expressions `P` or `Q` have type
2569
  “pointer to cv `T`”, where `T` and the array element type are not
2570
  similar [[conv.qual]], the behavior is undefined.
2571
 
 
2589
  additive-expression
2590
  shift-expression '<<' additive-expression
2591
  shift-expression '>>' additive-expression
2592
  ```
2593
 
2594
+ The operands shall be prvalues of integral or unscoped enumeration type
2595
+ and integral promotions are performed. The type of the result is that of
2596
+ the promoted left operand. The behavior is undefined if the right
2597
+ operand is negative, or greater than or equal to the width of the
2598
+ promoted left operand.
2599
 
2600
  The value of `E1 << E2` is the unique value congruent to `E1` × 2^`E2`
2601
  modulo 2ᴺ, where N is the width of the type of the result.
2602
 
2603
  [*Note 1*: `E1` is left-shifted `E2` bit positions; vacated bits are
2604
  zero-filled. — *end note*]
2605
 
2606
+ The value of `E1 >> E2` is `E1` / 2^`E2`, rounded towards negative
2607
+ infinity.
2608
 
2609
  [*Note 2*: `E1` is right-shifted `E2` bit positions. Right-shift on
2610
  signed integral types is an arithmetic right shift, which performs
2611
  sign-extension. — *end note*]
2612
 
 
2699
  relational-expression '>' compare-expression
2700
  relational-expression '<=' compare-expression
2701
  relational-expression '>=' compare-expression
2702
  ```
2703
 
2704
+ The lvalue-to-rvalue [[conv.lval]] and function-to-pointer [[conv.func]]
2705
+ standard conversions are performed on the operands. If one of the
2706
+ operands is a pointer, the array-to-pointer conversion [[conv.array]] is
2707
+ performed on the other operand.
2708
 
2709
  The converted operands shall have arithmetic, enumeration, or pointer
2710
  type. The operators `<` (less than), `>` (greater than), `<=` (less than
2711
  or equal to), and `>=` (greater than or equal to) all yield `false` or
2712
  `true`. The type of the result is `bool`.
2713
 
2714
  The usual arithmetic conversions [[expr.arith.conv]] are performed on
2715
+ operands of arithmetic or enumeration type. If both converted operands
2716
+ are pointers, pointer conversions [[conv.ptr]], function pointer
2717
+ conversions [[conv.fctptr]], and qualification conversions [[conv.qual]]
2718
+ are performed to bring them to their composite pointer type
2719
+ [[expr.type]]. After conversions, the operands shall have the same type.
2720
 
2721
+ The result of comparing unequal pointers to objects[^27]
2722
 
2723
  is defined in terms of a partial order consistent with the following
2724
  rules:
2725
 
2726
  - If two pointers point to different elements of the same array, or to
 
2740
  `p>q`, `q<=p`, and `q<p` all yield `true` and `p<=q`, `p<q`, `q>=p`, and
2741
  `q>p` all yield `false`. Otherwise, the result of each of the operators
2742
  is unspecified.
2743
 
2744
  [*Note 1*: A relational operator applied to unequal function pointers
2745
+ yields an unspecified result. A pointer value of type “pointer to
2746
+ cv `void`” can point to an object [[basic.compound]]. — *end note*]
2747
 
2748
  If both operands (after conversions) are of arithmetic or enumeration
2749
  type, each of the operators shall yield `true` if the specified
2750
  relationship is true and `false` if it is false.
2751
 
 
2757
  equality-expression '==' relational-expression
2758
  equality-expression '!=' relational-expression
2759
  ```
2760
 
2761
  The `==` (equal to) and the `!=` (not equal to) operators group
2762
+ left-to-right. The lvalue-to-rvalue [[conv.lval]] and
2763
+ function-to-pointer [[conv.func]] standard conversions are performed on
2764
+ the operands. If one of the operands is a pointer or a null pointer
2765
+ constant [[conv.ptr]], the array-to-pointer conversion [[conv.array]] is
2766
+ performed on the other operand.
2767
 
2768
+ The converted operands shall have scalar type. The operators `==` and
 
2769
  `!=` both yield `true` or `false`, i.e., a result of type `bool`. In
2770
  each case below, the operands shall have the same type after the
2771
  specified conversions have been applied.
2772
 
2773
+ If at least one of the converted operands is a pointer, pointer
2774
+ conversions [[conv.ptr]], function pointer conversions [[conv.fctptr]],
2775
+ and qualification conversions [[conv.qual]] are performed on both
2776
+ operands to bring them to their composite pointer type [[expr.type]].
2777
+ Comparing pointers is defined as follows:
2778
 
2779
  - If one pointer represents the address of a complete object, and
2780
  another pointer represents the address one past the last element of a
2781
+ different complete object,[^28] the result of the comparison is
2782
  unspecified.
2783
  - Otherwise, if the pointers are both null, both point to the same
2784
  function, or both represent the same address [[basic.compound]], they
2785
  compare equal.
2786
  - Otherwise, the pointers compare unequal.
 
2840
  — *end example*]
2841
 
2842
  Two operands of type `std::nullptr_t` or one operand of type
2843
  `std::nullptr_t` and the other a null pointer constant compare equal.
2844
 
2845
+ If both operands are of type `std::meta::info`, they compare equal if
2846
+ both operands
2847
+
2848
+ - are null reflection values,
2849
+ - represent values that are template-argument-equivalent [[temp.type]],
2850
+ - represent the same object,
2851
+ - represent the same entity,
2852
+ - represent the same annotation [[dcl.attr.annotation]],
2853
+ - represent the same direct base class relationship, or
2854
+ - represent equal data member descriptions [[class.mem.general]],
2855
+
2856
+ and they compare unequal otherwise.
2857
+
2858
  If two operands compare equal, the result is `true` for the `==`
2859
  operator and `false` for the `!=` operator. If two operands compare
2860
  unequal, the result is `false` for the `==` operator and `true` for the
2861
  `!=` operator. Otherwise, the result of each of the operators is
2862
  unspecified.
 
3011
  but an implicit conversion sequence can only be formed if the
3012
  reference would bind directly.
3013
  - If `E2` is a prvalue or if neither of the conversion sequences above
3014
  can be formed and at least one of the operands has (possibly
3015
  cv-qualified) class type:
3016
+ - if `T1` and `T2` are the same class type (ignoring
3017
+ cv-qualification):
3018
+ - if `T2` is at least as cv-qualified as `T1`, the target type is
3019
  `T2`,
3020
+ - otherwise, no conversion sequence is formed for this operand;
3021
  - otherwise, if `T2` is a base class of `T1`, the target type is *cv1*
3022
+ `T2`, where *cv1* denotes the cv-qualifiers of `T1`;
3023
  - otherwise, the target type is the type that `E2` would have after
3024
  applying the lvalue-to-rvalue [[conv.lval]], array-to-pointer
3025
  [[conv.array]], and function-to-pointer [[conv.func]] standard
3026
  conversions.
3027
 
3028
  Using this process, it is determined whether an implicit conversion
3029
  sequence can be formed from the second operand to the target type
3030
+ determined for the third operand, and vice versa, with the following
3031
+ outcome:
 
 
 
 
 
 
3032
 
3033
+ - If both sequences can be formed, or one can be formed but it is the
3034
+ ambiguous conversion sequence, the program is ill-formed.
3035
+ - If no conversion sequence can be formed, the operands are left
3036
+ unchanged and further checking is performed as described below.
3037
+ - Otherwise, if exactly one conversion sequence can be formed, that
3038
+ conversion is applied to the chosen operand and the converted operand
3039
+ is used in place of the original operand for the remainder of this
3040
+ subclause. \[*Note 3*: The conversion might be ill-formed even if an
3041
+ implicit conversion sequence could be formed. — *end note*]
3042
 
3043
  If the second and third operands are glvalues of the same value category
3044
  and have the same type, the result is of that type and value category
3045
  and it is a bit-field if the second or the third operand is a bit-field,
3046
  or if both are bit-fields.
 
3052
  the overload resolution fails, the program is ill-formed. Otherwise, the
3053
  conversions thus determined are applied, and the converted operands are
3054
  used in place of the original operands for the remainder of this
3055
  subclause.
3056
 
3057
+ Array-to-pointer [[conv.array]] and function-to-pointer [[conv.func]]
3058
+ standard conversions are performed on the second and third operands.
3059
+ After those conversions, one of the following shall hold:
 
3060
 
3061
  - The second and third operands have the same type; the result is of
3062
+ that type and the result is copy-initialized using the selected
3063
  operand.
3064
  - The second and third operands have arithmetic or enumeration type; the
3065
  usual arithmetic conversions [[expr.arith.conv]] are performed to
3066
  bring them to a common type, and the result is of that type.
3067
  - One or both of the second and third operands have pointer type;
3068
+ lvalue-to-rvalue [[conv.lval]], pointer [[conv.ptr]], function pointer
3069
  [[conv.fctptr]], and qualification conversions [[conv.qual]] are
3070
  performed to bring them to their composite pointer type [[expr.type]].
3071
  The result is of the composite pointer type.
3072
  - One or both of the second and third operands have pointer-to-member
3073
+ type; lvalue-to-rvalue [[conv.lval]], pointer to member [[conv.mem]],
3074
+ function pointer [[conv.fctptr]], and qualification conversions
3075
  [[conv.qual]] are performed to bring them to their composite pointer
3076
  type [[expr.type]]. The result is of the composite pointer type.
3077
  - Both the second and third operands have type `std::nullptr_t` or one
3078
  has that type and the other is a null pointer constant. The result is
3079
  of type `std::nullptr_t`.
3080
 
3081
  ### Yielding a value <a id="expr.yield">[[expr.yield]]</a>
3082
 
3083
  ``` bnf
3084
  yield-expression:
3085
+ co_yield assignment-expression
3086
+ co_yield braced-init-list
3087
  ```
3088
 
3089
  A *yield-expression* shall appear only within a suspension context of a
3090
  function [[expr.await]]. Let *e* be the operand of the
3091
  *yield-expression* and *p* be an lvalue naming the promise object of the
 
3137
  throw assignment-expressionₒₚₜ
3138
  ```
3139
 
3140
  A *throw-expression* is of type `void`.
3141
 
3142
+ A *throw-expression* with an operand throws an exception
3143
+ [[except.throw]]. The array-to-pointer [[conv.array]] and
3144
+ function-to-pointer [[conv.func]] standard conversions are performed on
3145
+ the operand. The type of the exception object is determined by removing
3146
+ any top-level *cv-qualifier*s from the type of the (possibly converted)
3147
+ operand. The exception object is copy-initialized [[dcl.init.general]]
3148
+ from the (possibly converted) operand.
3149
 
3150
  A *throw-expression* with no operand rethrows the currently handled
3151
+ exception [[except.handle]]. If no exception is presently being handled,
3152
+ the function `std::terminate` is invoked [[except.terminate]].
3153
+ Otherwise, the exception is reactivated with the existing exception
3154
+ object; no new exception object is created. The exception is no longer
3155
+ considered to be caught.
3156
 
3157
  [*Example 1*:
3158
 
3159
  An exception handler that cannot completely handle the exception itself
3160
  can be written like this:
 
3168
  }
3169
  ```
3170
 
3171
  — *end example*]
3172
 
3173
+ ### Assignment and compound assignment operators <a id="expr.assign">[[expr.assign]]</a>
 
 
 
 
3174
 
3175
  The assignment operator (`=`) and the compound assignment operators all
3176
  group right-to-left. All require a modifiable lvalue as their left
3177
  operand; their result is an lvalue of the type of the left operand,
3178
  referring to the left operand. The result in all cases is a bit-field if
 
3198
  ``` bnf
3199
  assignment-operator: one of
3200
  '= *= /= %= += -= >>= <<= &= ^= |='
3201
  ```
3202
 
3203
+ In simple assignment (`=`), let `V` be the result of the right operand;
3204
+ the object referred to by the left operand is modified [[defns.access]]
3205
+ by replacing its value with `V` or, if the object is of integer type,
3206
+ with the value congruent [[basic.fundamental]] to `V`.
3207
 
3208
  If the right operand is an expression, it is implicitly converted
3209
  [[conv]] to the cv-unqualified type of the left operand.
3210
 
3211
  When the left operand of an assignment operator is a bit-field that
 
3235
  [*Note 3*: This restriction applies to the relationship between the
3236
  left and right sides of the assignment operation; it is not a statement
3237
  about how the target of the assignment can be aliased in general. See 
3238
  [[basic.lval]]. — *end note*]
3239
 
3240
+ A *braced-init-list* B may appear on the right-hand side of
3241
 
3242
+ - an assignment to a scalar of type `T`, in which case B shall have at
3243
+ most a single element. The meaning of `x = B` is `x = t`, where `t` is
3244
+ an invented temporary variable declared and initialized as `T t = B`.
3245
+ - an assignment to an object of class type, in which case B is passed as
3246
+ the argument to the assignment operator function selected by overload
3247
+ resolution [[over.assign]], [[over.match]].
 
3248
 
3249
  [*Example 1*:
3250
 
3251
  ``` cpp
3252
  complex<double> z;