From Jason Turner

[basic.lval]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmnb_ynj0/{from.md → to.md} +35 -30
tmp/tmpmnb_ynj0/{from.md → to.md} RENAMED
@@ -6,22 +6,22 @@ Expressions are categorized according to the taxonomy in Figure
6
  <a id="fig:basic.lval"></a>
7
 
8
  ![Expression category taxonomy \[fig:basic.lval\]](images/valuecategories.svg)
9
 
10
  - A *glvalue* is an expression whose evaluation determines the identity
11
- of an object or function.
12
  - A *prvalue* is an expression whose evaluation initializes an object or
13
  computes the value of an operand of an operator, as specified by the
14
  context in which it appears, or an expression that has type cv `void`.
15
  - An *xvalue* is a glvalue that denotes an object whose resources can be
16
  reused (usually because it is near the end of its lifetime).
17
  - An *lvalue* is a glvalue that is not an xvalue.
18
  - An *rvalue* is a prvalue or an xvalue.
19
 
20
- Every expression belongs to exactly one of the fundamental
21
- classifications in this taxonomy: lvalue, xvalue, or prvalue. This
22
- property of an expression is called its *value category*.
23
 
24
  [*Note 1*: The discussion of each built-in operator in
25
  [[expr.compound]] indicates the category of the value it yields and the
26
  value categories of the operands it expects. For example, the built-in
27
  assignment operators expect that the left operand is an lvalue and that
@@ -32,18 +32,19 @@ types. — *end note*]
32
 
33
  [*Note 2*: Historically, lvalues and rvalues were so-called because
34
  they could appear on the left- and right-hand side of an assignment
35
  (although this is no longer generally true); glvalues are “generalized”
36
  lvalues, prvalues are “pure” rvalues, and xvalues are “eXpiring”
37
- lvalues. Despite their names, these terms classify expressions, not
38
  values. — *end note*]
39
 
40
  [*Note 3*:
41
 
42
  An expression is an xvalue if it is:
43
 
44
- - a move-eligible *id-expression* [[expr.prim.id.unqual]],
 
45
  - the result of calling a function, whether implicitly or explicitly,
46
  whose return type is an rvalue reference to object type [[expr.call]],
47
  - a cast to an rvalue reference to object type
48
  [[expr.type.conv]], [[expr.dynamic.cast]], [[expr.static.cast]], [[expr.reinterpret.cast]], [[expr.const.cast]], [[expr.cast]],
49
  - a subscripting operation with an xvalue array operand [[expr.sub]],
@@ -82,21 +83,18 @@ xvalues. The expression `ar` is an lvalue.
82
  The *result* of a glvalue is the entity denoted by the expression. The
83
  *result* of a prvalue is the value that the expression stores into its
84
  context; a prvalue that has type cv `void` has no result. A prvalue
85
  whose result is the value *V* is sometimes said to have or name the
86
  value *V*. The *result object* of a prvalue is the object initialized by
87
- the prvalue; a non-discarded prvalue that is used to compute the value
88
- of an operand of a built-in operator or a prvalue that has type
89
- cv `void` has no result object.
90
 
91
  [*Note 4*: Except when the prvalue is the operand of a
92
- *decltype-specifier*, a prvalue of class or array type always has a
93
- result object. For a discarded prvalue that has type other than
94
- cv `void`, a temporary object is materialized; see
95
- [[expr.context]]. — *end note*]
96
 
97
- Whenever a glvalue appears as an operand of an operator that expects 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,48 +107,55 @@ prvalue of type `int` is required. — *end note*]
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
- Whenever a prvalue appears as an operand of an operator that expects a
115
- glvalue for that operand, the temporary materialization conversion
116
- [[conv.rval]] is applied to convert the expression to an xvalue.
 
 
 
117
 
118
- The discussion of reference initialization in  [[dcl.init.ref]] and of
119
- temporaries in  [[class.temporary]] indicates the behavior of lvalues
120
- and rvalues in other significant contexts.
 
121
 
122
  Unless otherwise indicated [[dcl.type.decltype]], a prvalue shall always
123
  have complete type or the `void` type; if it has a class type or
124
  (possibly multidimensional) array of class type, that class shall not be
125
  an abstract class [[class.abstract]]. A glvalue shall not have type
126
  cv `void`.
127
 
128
- [*Note 8*: A glvalue can have complete or incomplete non-`void` type.
129
  Class and array prvalues can have cv-qualified types; other prvalues
130
  always have cv-unqualified types. See [[expr.type]]. — *end note*]
131
 
132
  An lvalue is *modifiable* unless its type is const-qualified or is a
133
  function type.
134
 
135
- [*Note 9*: A program that attempts to modify an object through a
136
  nonmodifiable lvalue or through an rvalue is ill-formed
137
- [[expr.ass]], [[expr.post.incr]], [[expr.pre.incr]]. — *end note*]
138
 
139
- If a program attempts to access [[defns.access]] the stored value of an
140
- object through a glvalue whose type is not similar [[conv.qual]] to one
141
- of the following types the behavior is undefined:[^4]
142
 
143
- - the dynamic type of the object,
144
- - a type that is the signed or unsigned type corresponding to the
145
- dynamic type of the object, or
146
  - a `char`, `unsigned char`, or `std::byte` type.
147
 
 
 
 
 
148
  If a program invokes a defaulted copy/move constructor or copy/move
149
  assignment operator for a union of type `U` with a glvalue argument that
150
  does not denote an object of type cv `U` within its lifetime, the
151
  behavior is undefined.
152
 
153
- [*Note 10*: In C, an entire object of structure type can be accessed,
154
  e.g., using assignment. By contrast, C++ has no notion of accessing an
155
  object of class type through an lvalue of class type. — *end note*]
156
 
 
6
  <a id="fig:basic.lval"></a>
7
 
8
  ![Expression category taxonomy \[fig:basic.lval\]](images/valuecategories.svg)
9
 
10
  - A *glvalue* is an expression whose evaluation determines the identity
11
+ of an object, function, or non-static data member.
12
  - A *prvalue* is an expression whose evaluation initializes an object or
13
  computes the value of an operand of an operator, as specified by the
14
  context in which it appears, or an expression that has type cv `void`.
15
  - An *xvalue* is a glvalue that denotes an object whose resources can be
16
  reused (usually because it is near the end of its lifetime).
17
  - An *lvalue* is a glvalue that is not an xvalue.
18
  - An *rvalue* is a prvalue or an xvalue.
19
 
20
+ Every expression belongs to exactly one of the fundamental categories in
21
+ this taxonomy: lvalue, xvalue, or prvalue. This property of an
22
+ expression is called its *value category*.
23
 
24
  [*Note 1*: The discussion of each built-in operator in
25
  [[expr.compound]] indicates the category of the value it yields and the
26
  value categories of the operands it expects. For example, the built-in
27
  assignment operators expect that the left operand is an lvalue and that
 
32
 
33
  [*Note 2*: Historically, lvalues and rvalues were so-called because
34
  they could appear on the left- and right-hand side of an assignment
35
  (although this is no longer generally true); glvalues are “generalized”
36
  lvalues, prvalues are “pure” rvalues, and xvalues are “eXpiring”
37
+ lvalues. Despite their names, these terms apply to expressions, not
38
  values. — *end note*]
39
 
40
  [*Note 3*:
41
 
42
  An expression is an xvalue if it is:
43
 
44
+ - a move-eligible *id-expression* [[expr.prim.id.unqual]] or
45
+ *splice-expression* [[expr.prim.splice]],
46
  - the result of calling a function, whether implicitly or explicitly,
47
  whose return type is an rvalue reference to object type [[expr.call]],
48
  - a cast to an rvalue reference to object type
49
  [[expr.type.conv]], [[expr.dynamic.cast]], [[expr.static.cast]], [[expr.reinterpret.cast]], [[expr.const.cast]], [[expr.cast]],
50
  - a subscripting operation with an xvalue array operand [[expr.sub]],
 
83
  The *result* of a glvalue is the entity denoted by the expression. The
84
  *result* of a prvalue is the value that the expression stores into its
85
  context; a prvalue that has type cv `void` has no result. A prvalue
86
  whose result is the value *V* is sometimes said to have or name the
87
  value *V*. The *result object* of a prvalue is the object initialized by
88
+ the prvalue; a prvalue that has type cv `void` has no result object.
 
 
89
 
90
  [*Note 4*: Except when the prvalue is the operand of a
91
+ *decltype-specifier*, a prvalue of object type always has a result
92
+ object. For a discarded prvalue that has type other than cv `void`, a
93
+ temporary object is materialized; see [[expr.context]]. — *end note*]
 
94
 
95
+ Whenever a glvalue appears as an operand of an operator that requires a
96
  prvalue for that operand, the lvalue-to-rvalue [[conv.lval]],
97
  array-to-pointer [[conv.array]], or function-to-pointer [[conv.func]]
98
  standard conversions are applied to convert the expression to a prvalue.
99
 
100
  [*Note 5*: An attempt to bind an rvalue reference to an lvalue is not
 
107
 
108
  [*Note 7*: There are no prvalue bit-fields; if a bit-field is converted
109
  to a prvalue [[conv.lval]], a prvalue of the type of the bit-field is
110
  created, which might then be promoted [[conv.prom]]. — *end note*]
111
 
112
+ Unless otherwise specified
113
+ [[expr.reinterpret.cast]], [[expr.const.cast]], whenever a prvalue that
114
+ is not the result of the lvalue-to-rvalue conversion [[conv.lval]]
115
+ appears as an operand of an operator, the temporary materialization
116
+ conversion [[conv.rval]] is applied to convert the expression to an
117
+ xvalue.
118
 
119
+ [*Note 8*: The discussion of reference initialization in 
120
+ [[dcl.init.ref]] and of temporaries in  [[class.temporary]] indicates
121
+ the behavior of lvalues and rvalues in other significant
122
+ contexts. — *end note*]
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 9*: 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 10*: A program that attempts to modify an object through a
138
  nonmodifiable lvalue or through an rvalue is ill-formed
139
+ [[expr.assign]], [[expr.post.incr]], [[expr.pre.incr]]. — *end note*]
140
 
141
+ An object of dynamic type `T`_obj is *type-accessible* through a glvalue
142
+ of type `T`_ref if `T`_ref is similar [[conv.qual]] to:
 
143
 
144
+ - `T`_obj,
145
+ - a type that is the signed or unsigned type corresponding to `T`_obj,
146
+ or
147
  - a `char`, `unsigned char`, or `std::byte` type.
148
 
149
+ If a program attempts to access [[defns.access]] the stored value of an
150
+ object through a glvalue through which it is not type-accessible, the
151
+ behavior is undefined.[^4]
152
+
153
  If a program invokes a defaulted copy/move constructor or copy/move
154
  assignment operator for a union of type `U` with a glvalue argument that
155
  does not denote an object of type cv `U` within its lifetime, the
156
  behavior is undefined.
157
 
158
+ [*Note 11*: In C, an entire object of structure type can be accessed,
159
  e.g., using assignment. By contrast, C++ has no notion of accessing an
160
  object of class type through an lvalue of class type. — *end note*]
161