From Jason Turner

[expr.prop]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpewctjrhy/{from.md → to.md} +47 -39
tmp/tmpewctjrhy/{from.md → to.md} RENAMED
@@ -8,22 +8,22 @@ Expressions are categorized according to the taxonomy in Figure
8
  <a id="fig:basic.lval"></a>
9
 
10
  ![Expression category taxonomy \[fig:basic.lval\]](images/valuecategories.svg)
11
 
12
  - A *glvalue* is an expression whose evaluation determines the identity
13
- of an object or function.
14
  - A *prvalue* is an expression whose evaluation initializes an object or
15
  computes the value of an operand of an operator, as specified by the
16
  context in which it appears, or an expression that has type cv `void`.
17
  - An *xvalue* is a glvalue that denotes an object whose resources can be
18
  reused (usually because it is near the end of its lifetime).
19
  - An *lvalue* is a glvalue that is not an xvalue.
20
  - An *rvalue* is a prvalue or an xvalue.
21
 
22
- Every expression belongs to exactly one of the fundamental
23
- classifications in this taxonomy: lvalue, xvalue, or prvalue. This
24
- property of an expression is called its *value category*.
25
 
26
  [*Note 1*: The discussion of each built-in operator in
27
  [[expr.compound]] indicates the category of the value it yields and the
28
  value categories of the operands it expects. For example, the built-in
29
  assignment operators expect that the left operand is an lvalue and that
@@ -34,18 +34,19 @@ types. — *end note*]
34
 
35
  [*Note 2*: Historically, lvalues and rvalues were so-called because
36
  they could appear on the left- and right-hand side of an assignment
37
  (although this is no longer generally true); glvalues are “generalized”
38
  lvalues, prvalues are “pure” rvalues, and xvalues are “eXpiring”
39
- lvalues. Despite their names, these terms classify expressions, not
40
  values. — *end note*]
41
 
42
  [*Note 3*:
43
 
44
  An expression is an xvalue if it is:
45
 
46
- - a move-eligible *id-expression* [[expr.prim.id.unqual]],
 
47
  - the result of calling a function, whether implicitly or explicitly,
48
  whose return type is an rvalue reference to object type [[expr.call]],
49
  - a cast to an rvalue reference to object type
50
  [[expr.type.conv]], [[expr.dynamic.cast]], [[expr.static.cast]], [[expr.reinterpret.cast]], [[expr.const.cast]], [[expr.cast]],
51
  - a subscripting operation with an xvalue array operand [[expr.sub]],
@@ -84,21 +85,18 @@ xvalues. The expression `ar` is an lvalue.
84
  The *result* of a glvalue is the entity denoted by the expression. The
85
  *result* of a prvalue is the value that the expression stores into its
86
  context; a prvalue that has type cv `void` has no result. A prvalue
87
  whose result is the value *V* is sometimes said to have or name the
88
  value *V*. The *result object* of a prvalue is the object initialized by
89
- the prvalue; a non-discarded prvalue that is used to compute the value
90
- of an operand of a built-in operator or a prvalue that has type
91
- cv `void` has no result object.
92
 
93
  [*Note 4*: Except when the prvalue is the operand of a
94
- *decltype-specifier*, a prvalue of class or array type always has a
95
- result object. For a discarded prvalue that has type other than
96
- cv `void`, a temporary object is materialized; see
97
- [[expr.context]]. — *end note*]
98
 
99
- Whenever a glvalue appears as an operand of an operator that expects a
100
  prvalue for that operand, the lvalue-to-rvalue [[conv.lval]],
101
  array-to-pointer [[conv.array]], or function-to-pointer [[conv.func]]
102
  standard conversions are applied to convert the expression to a prvalue.
103
 
104
  [*Note 5*: An attempt to bind an rvalue reference to an lvalue is not
@@ -111,60 +109,69 @@ prvalue of type `int` is required. — *end note*]
111
 
112
  [*Note 7*: There are no prvalue bit-fields; if a bit-field is converted
113
  to a prvalue [[conv.lval]], a prvalue of the type of the bit-field is
114
  created, which might then be promoted [[conv.prom]]. — *end note*]
115
 
116
- Whenever a prvalue appears as an operand of an operator that expects a
117
- glvalue for that operand, the temporary materialization conversion
118
- [[conv.rval]] is applied to convert the expression to an xvalue.
 
 
 
119
 
120
- The discussion of reference initialization in  [[dcl.init.ref]] and of
121
- temporaries in  [[class.temporary]] indicates the behavior of lvalues
122
- and rvalues in other significant contexts.
 
123
 
124
  Unless otherwise indicated [[dcl.type.decltype]], a prvalue shall always
125
  have complete type or the `void` type; if it has a class type or
126
  (possibly multidimensional) array of class type, that class shall not be
127
  an abstract class [[class.abstract]]. A glvalue shall not have type
128
  cv `void`.
129
 
130
- [*Note 8*: A glvalue can have complete or incomplete non-`void` type.
131
  Class and array prvalues can have cv-qualified types; other prvalues
132
  always have cv-unqualified types. See [[expr.type]]. — *end note*]
133
 
134
  An lvalue is *modifiable* unless its type is const-qualified or is a
135
  function type.
136
 
137
- [*Note 9*: A program that attempts to modify an object through a
138
  nonmodifiable lvalue or through an rvalue is ill-formed
139
- [[expr.ass]], [[expr.post.incr]], [[expr.pre.incr]]. — *end note*]
140
 
141
- If a program attempts to access [[defns.access]] the stored value of an
142
- object through a glvalue whose type is not similar [[conv.qual]] to one
143
- of the following types the behavior is undefined:[^4]
144
 
145
- - the dynamic type of the object,
146
- - a type that is the signed or unsigned type corresponding to the
147
- dynamic type of the object, or
148
  - a `char`, `unsigned char`, or `std::byte` type.
149
 
 
 
 
 
150
  If a program invokes a defaulted copy/move constructor or copy/move
151
  assignment operator for a union of type `U` with a glvalue argument that
152
  does not denote an object of type cv `U` within its lifetime, the
153
  behavior is undefined.
154
 
155
- [*Note 10*: In C, an entire object of structure type can be accessed,
156
  e.g., using assignment. By contrast, C++ has no notion of accessing an
157
  object of class type through an lvalue of class type. — *end note*]
158
 
159
  ### Type <a id="expr.type">[[expr.type]]</a>
160
 
161
  If an expression initially has the type “reference to `T`”
162
  [[dcl.ref]], [[dcl.init.ref]], the type is adjusted to `T` prior to any
163
- further analysis. The expression designates the object or function
164
- denoted by the reference, and the expression is an lvalue or an xvalue,
165
- depending on the expression.
 
 
166
 
167
  [*Note 1*: Before the lifetime of the reference has started or after it
168
  has ended, the behavior is undefined (see 
169
  [[basic.life]]). — *end note*]
170
 
@@ -184,15 +191,15 @@ pointer-to-member type or `std::nullptr_t`, is:
184
  “pointer to *cv12* `void`”, where *cv12* is the union of *cv1* and
185
  *cv2*;
186
  - if `T1` or `T2` is “pointer to `noexcept` function” and the other type
187
  is “pointer to function”, where the function types are otherwise the
188
  same, “pointer to function”;
189
- - if `T1` is “pointer to *cv1* `C1`” and `T2` is “pointer to *cv2*
190
- `C2`”, where `C1` is reference-related to `C2` or `C2` is
191
- reference-related to `C1` [[dcl.init.ref]], the qualification-combined
192
- type [[conv.qual]] of `T1` and `T2` or the qualification-combined type
193
- of `T2` and `T1`, respectively;
194
  - if `T1` or `T2` is “pointer to member of `C1` of type function”, the
195
  other type is “pointer to member of `C2` of type `noexcept` function”,
196
  and `C1` is reference-related to `C2` or `C2` is reference-related to
197
  `C1` [[dcl.init.ref]], where the function types are otherwise the
198
  same, “pointer to member of `C2` of type function” or “pointer to
@@ -224,11 +231,11 @@ pointer to `const int`”.
224
  — *end example*]
225
 
226
  ### Context dependence <a id="expr.context">[[expr.context]]</a>
227
 
228
  In some contexts, *unevaluated operands* appear
229
- [[expr.prim.req]], [[expr.typeid]], [[expr.sizeof]], [[expr.unary.noexcept]], [[dcl.type.decltype]], [[temp.pre]], [[temp.concept]].
230
  An unevaluated operand is not evaluated.
231
 
232
  [*Note 1*: In an unevaluated operand, a non-static class member can be
233
  named [[expr.prim.id]] and naming of objects or functions does not, by
234
  itself, require that a definition be provided [[basic.def.odr]]. An
@@ -242,10 +249,11 @@ standard conversions are not applied. The lvalue-to-rvalue conversion
242
  [[conv.lval]] is applied if and only if the expression is a glvalue of
243
  volatile-qualified type and it is one of the following:
244
 
245
  - `(` *expression* `)`, where *expression* is one of these expressions,
246
  - *id-expression* [[expr.prim.id]],
 
247
  - subscripting [[expr.sub]],
248
  - class member access [[expr.ref]],
249
  - indirection [[expr.unary.op]],
250
  - pointer-to-member operation [[expr.mptr.oper]],
251
  - conditional expression [[expr.cond]] where both the second and the
 
8
  <a id="fig:basic.lval"></a>
9
 
10
  ![Expression category taxonomy \[fig:basic.lval\]](images/valuecategories.svg)
11
 
12
  - A *glvalue* is an expression whose evaluation determines the identity
13
+ of an object, function, or non-static data member.
14
  - A *prvalue* is an expression whose evaluation initializes an object or
15
  computes the value of an operand of an operator, as specified by the
16
  context in which it appears, or an expression that has type cv `void`.
17
  - An *xvalue* is a glvalue that denotes an object whose resources can be
18
  reused (usually because it is near the end of its lifetime).
19
  - An *lvalue* is a glvalue that is not an xvalue.
20
  - An *rvalue* is a prvalue or an xvalue.
21
 
22
+ Every expression belongs to exactly one of the fundamental categories in
23
+ this taxonomy: lvalue, xvalue, or prvalue. This property of an
24
+ expression is called its *value category*.
25
 
26
  [*Note 1*: The discussion of each built-in operator in
27
  [[expr.compound]] indicates the category of the value it yields and the
28
  value categories of the operands it expects. For example, the built-in
29
  assignment operators expect that the left operand is an lvalue and that
 
34
 
35
  [*Note 2*: Historically, lvalues and rvalues were so-called because
36
  they could appear on the left- and right-hand side of an assignment
37
  (although this is no longer generally true); glvalues are “generalized”
38
  lvalues, prvalues are “pure” rvalues, and xvalues are “eXpiring”
39
+ lvalues. Despite their names, these terms apply to expressions, not
40
  values. — *end note*]
41
 
42
  [*Note 3*:
43
 
44
  An expression is an xvalue if it is:
45
 
46
+ - a move-eligible *id-expression* [[expr.prim.id.unqual]] or
47
+ *splice-expression* [[expr.prim.splice]],
48
  - the result of calling a function, whether implicitly or explicitly,
49
  whose return type is an rvalue reference to object type [[expr.call]],
50
  - a cast to an rvalue reference to object type
51
  [[expr.type.conv]], [[expr.dynamic.cast]], [[expr.static.cast]], [[expr.reinterpret.cast]], [[expr.const.cast]], [[expr.cast]],
52
  - a subscripting operation with an xvalue array operand [[expr.sub]],
 
85
  The *result* of a glvalue is the entity denoted by the expression. The
86
  *result* of a prvalue is the value that the expression stores into its
87
  context; a prvalue that has type cv `void` has no result. A prvalue
88
  whose result is the value *V* is sometimes said to have or name the
89
  value *V*. The *result object* of a prvalue is the object initialized by
90
+ the prvalue; a prvalue that has type cv `void` has no result object.
 
 
91
 
92
  [*Note 4*: Except when the prvalue is the operand of a
93
+ *decltype-specifier*, a prvalue of object type always has a result
94
+ object. For a discarded prvalue that has type other than cv `void`, a
95
+ temporary object is materialized; see [[expr.context]]. — *end note*]
 
96
 
97
+ Whenever a glvalue appears as an operand of an operator that requires a
98
  prvalue for that operand, the lvalue-to-rvalue [[conv.lval]],
99
  array-to-pointer [[conv.array]], or function-to-pointer [[conv.func]]
100
  standard conversions are applied to convert the expression to a prvalue.
101
 
102
  [*Note 5*: An attempt to bind an rvalue reference to an lvalue is not
 
109
 
110
  [*Note 7*: There are no prvalue bit-fields; if a bit-field is converted
111
  to a prvalue [[conv.lval]], a prvalue of the type of the bit-field is
112
  created, which might then be promoted [[conv.prom]]. — *end note*]
113
 
114
+ Unless otherwise specified
115
+ [[expr.reinterpret.cast]], [[expr.const.cast]], whenever a prvalue that
116
+ is not the result of the lvalue-to-rvalue conversion [[conv.lval]]
117
+ appears as an operand of an operator, the temporary materialization
118
+ conversion [[conv.rval]] is applied to convert the expression to an
119
+ xvalue.
120
 
121
+ [*Note 8*: The discussion of reference initialization in 
122
+ [[dcl.init.ref]] and of temporaries in  [[class.temporary]] indicates
123
+ the behavior of lvalues and rvalues in other significant
124
+ contexts. — *end note*]
125
 
126
  Unless otherwise indicated [[dcl.type.decltype]], a prvalue shall always
127
  have complete type or the `void` type; if it has a class type or
128
  (possibly multidimensional) array of class type, that class shall not be
129
  an abstract class [[class.abstract]]. A glvalue shall not have type
130
  cv `void`.
131
 
132
+ [*Note 9*: A glvalue can have complete or incomplete non-`void` type.
133
  Class and array prvalues can have cv-qualified types; other prvalues
134
  always have cv-unqualified types. See [[expr.type]]. — *end note*]
135
 
136
  An lvalue is *modifiable* unless its type is const-qualified or is a
137
  function type.
138
 
139
+ [*Note 10*: A program that attempts to modify an object through a
140
  nonmodifiable lvalue or through an rvalue is ill-formed
141
+ [[expr.assign]], [[expr.post.incr]], [[expr.pre.incr]]. — *end note*]
142
 
143
+ An object of dynamic type `T`_obj is *type-accessible* through a glvalue
144
+ of type `T`_ref if `T`_ref is similar [[conv.qual]] to:
 
145
 
146
+ - `T`_obj,
147
+ - a type that is the signed or unsigned type corresponding to `T`_obj,
148
+ or
149
  - a `char`, `unsigned char`, or `std::byte` type.
150
 
151
+ If a program attempts to access [[defns.access]] the stored value of an
152
+ object through a glvalue through which it is not type-accessible, the
153
+ behavior is undefined.[^4]
154
+
155
  If a program invokes a defaulted copy/move constructor or copy/move
156
  assignment operator for a union of type `U` with a glvalue argument that
157
  does not denote an object of type cv `U` within its lifetime, the
158
  behavior is undefined.
159
 
160
+ [*Note 11*: In C, an entire object of structure type can be accessed,
161
  e.g., using assignment. By contrast, C++ has no notion of accessing an
162
  object of class type through an lvalue of class type. — *end note*]
163
 
164
  ### Type <a id="expr.type">[[expr.type]]</a>
165
 
166
  If an expression initially has the type “reference to `T`”
167
  [[dcl.ref]], [[dcl.init.ref]], the type is adjusted to `T` prior to any
168
+ further analysis; the value category of the expression is not altered.
169
+ Let X be the object or function denoted by the reference. If a pointer
170
+ to X would be valid in the context of the evaluation of the expression
171
+ [[basic.fundamental]], the result designates X; otherwise, the behavior
172
+ is undefined.
173
 
174
  [*Note 1*: Before the lifetime of the reference has started or after it
175
  has ended, the behavior is undefined (see 
176
  [[basic.life]]). — *end note*]
177
 
 
191
  “pointer to *cv12* `void`”, where *cv12* is the union of *cv1* and
192
  *cv2*;
193
  - if `T1` or `T2` is “pointer to `noexcept` function” and the other type
194
  is “pointer to function”, where the function types are otherwise the
195
  same, “pointer to function”;
196
+ - if `T1` is “pointer to `C1`” and `T2` is “pointer to `C2`”, where `C1`
197
+ is reference-related to `C2` or `C2` is reference-related to `C1`
198
+ [[dcl.init.ref]], the qualification-combined type [[conv.qual]] of
199
+ `T1` and `T2` or the qualification-combined type of `T2` and `T1`,
200
+ respectively;
201
  - if `T1` or `T2` is “pointer to member of `C1` of type function”, the
202
  other type is “pointer to member of `C2` of type `noexcept` function”,
203
  and `C1` is reference-related to `C2` or `C2` is reference-related to
204
  `C1` [[dcl.init.ref]], where the function types are otherwise the
205
  same, “pointer to member of `C2` of type function” or “pointer to
 
231
  — *end example*]
232
 
233
  ### Context dependence <a id="expr.context">[[expr.context]]</a>
234
 
235
  In some contexts, *unevaluated operands* appear
236
+ [[expr.prim.req.simple]], [[expr.prim.req.compound]], [[expr.typeid]], [[expr.sizeof]], [[expr.unary.noexcept]], [[expr.reflect]], [[dcl.type.decltype]], [[temp.pre]], [[temp.concept]].
237
  An unevaluated operand is not evaluated.
238
 
239
  [*Note 1*: In an unevaluated operand, a non-static class member can be
240
  named [[expr.prim.id]] and naming of objects or functions does not, by
241
  itself, require that a definition be provided [[basic.def.odr]]. An
 
249
  [[conv.lval]] is applied if and only if the expression is a glvalue of
250
  volatile-qualified type and it is one of the following:
251
 
252
  - `(` *expression* `)`, where *expression* is one of these expressions,
253
  - *id-expression* [[expr.prim.id]],
254
+ - *splice-expression* [[expr.prim.splice]],
255
  - subscripting [[expr.sub]],
256
  - class member access [[expr.ref]],
257
  - indirection [[expr.unary.op]],
258
  - pointer-to-member operation [[expr.mptr.oper]],
259
  - conditional expression [[expr.cond]] where both the second and the