- tmp/tmpjups8sv8/{from.md → to.md} +116 -69
tmp/tmpjups8sv8/{from.md → to.md}
RENAMED
|
@@ -1,110 +1,157 @@
|
|
| 1 |
-
##
|
| 2 |
|
| 3 |
-
Expressions are categorized according to the taxonomy in Figure
|
| 4 |
-
[[fig:
|
| 5 |
|
| 6 |
-
<a id="fig:
|
| 7 |
|
| 8 |
-
![Expression category taxonomy \[fig:
|
| 9 |
|
| 10 |
- A *glvalue* is an expression whose evaluation determines the identity
|
| 11 |
of an object, bit-field, or function.
|
| 12 |
- A *prvalue* is an expression whose evaluation initializes an object or
|
| 13 |
-
a bit-field, or computes the value of
|
| 14 |
-
specified by the context in which it appears
|
|
|
|
| 15 |
- An *xvalue* is a glvalue that denotes an object or bit-field whose
|
| 16 |
resources can be reused (usually because it is near the end of its
|
| 17 |
-
lifetime).
|
| 18 |
-
rvalue references ([[dcl.ref]]) yield xvalues, such as a call to a
|
| 19 |
-
function whose return type is an rvalue reference or a cast to an
|
| 20 |
-
rvalue reference type. — *end example*]
|
| 21 |
- An *lvalue* is a glvalue that is not an xvalue.
|
| 22 |
- An *rvalue* is a prvalue or an xvalue.
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
they could appear on the left- and right-hand side of an assignment
|
| 26 |
(although this is no longer generally true); glvalues are “generalized”
|
| 27 |
lvalues, prvalues are “pure” rvalues, and xvalues are “eXpiring”
|
| 28 |
lvalues. Despite their names, these terms classify expressions, not
|
| 29 |
values. — *end note*]
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
*decltype-specifier*, a prvalue of class or array type always has a
|
| 52 |
-
result object. For a discarded prvalue
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
[*Note
|
| 58 |
-
|
| 59 |
-
[[conv.array]], and [[conv.func]]. An attempt to bind an rvalue
|
| 60 |
-
reference to an lvalue is not such a context; see
|
| 61 |
-
[[dcl.init.ref]]. — *end note*]
|
| 62 |
|
| 63 |
-
[*Note
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
|
| 67 |
-
[*Note
|
| 68 |
-
|
| 69 |
-
[[conv.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
The discussion of reference initialization in [[dcl.init.ref]] and of
|
| 72 |
temporaries in [[class.temporary]] indicates the behavior of lvalues
|
| 73 |
and rvalues in other significant contexts.
|
| 74 |
|
| 75 |
-
Unless otherwise indicated
|
| 76 |
-
complete type or the `void` type
|
|
|
|
|
|
|
| 77 |
cv `void`.
|
| 78 |
|
| 79 |
-
[*Note
|
| 80 |
Class and array prvalues can have cv-qualified types; other prvalues
|
| 81 |
-
always have cv-unqualified types. See
|
| 82 |
|
| 83 |
An lvalue is *modifiable* unless its type is const-qualified or is a
|
| 84 |
function type.
|
| 85 |
|
| 86 |
-
[*Note
|
| 87 |
-
nonmodifiable lvalue
|
| 88 |
-
|
| 89 |
-
[[expr.pre.incr]]). — *end note*]
|
| 90 |
|
| 91 |
-
If a program attempts to access the stored value of an
|
| 92 |
-
|
| 93 |
-
undefined:[^
|
| 94 |
|
| 95 |
- the dynamic type of the object,
|
| 96 |
-
- a cv-qualified version of the dynamic type of the object,
|
| 97 |
-
- a type similar (as defined in [[conv.qual]]) to the dynamic type of
|
| 98 |
-
the object,
|
| 99 |
- a type that is the signed or unsigned type corresponding to the
|
| 100 |
-
dynamic type of the object,
|
| 101 |
-
- a type that is the signed or unsigned type corresponding to a
|
| 102 |
-
cv-qualified version of the dynamic type of the object,
|
| 103 |
-
- an aggregate or union type that includes one of the aforementioned
|
| 104 |
-
types among its elements or non-static data members (including,
|
| 105 |
-
recursively, an element or non-static data member of a subaggregate or
|
| 106 |
-
contained union),
|
| 107 |
-
- a type that is a (possibly cv-qualified) base class type of the
|
| 108 |
-
dynamic type of the object,
|
| 109 |
- a `char`, `unsigned char`, or `std::byte` type.
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Value category <a id="basic.lval">[[basic.lval]]</a>
|
| 2 |
|
| 3 |
+
Expressions are categorized according to the taxonomy in Figure
|
| 4 |
+
[[fig:basic.lval]].
|
| 5 |
|
| 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, bit-field, or function.
|
| 12 |
- A *prvalue* is an expression whose evaluation initializes an object or
|
| 13 |
+
a bit-field, or computes the value of an operand of an operator, as
|
| 14 |
+
specified by the context in which it appears, or an expression that
|
| 15 |
+
has type cv `void`.
|
| 16 |
- An *xvalue* is a glvalue that denotes an object or bit-field whose
|
| 17 |
resources can be reused (usually because it is near the end of its
|
| 18 |
+
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
|
| 30 |
+
the right operand is a prvalue and yield an lvalue as the result.
|
| 31 |
+
User-defined operators are functions, and the categories of values they
|
| 32 |
+
expect and yield are determined by their parameter and return
|
| 33 |
+
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 |
+
- 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 ([[expr.type.conv]],
|
| 49 |
+
[[expr.dynamic.cast]], [[expr.static.cast]] [[expr.reinterpret.cast]],
|
| 50 |
+
[[expr.const.cast]], [[expr.cast]]),
|
| 51 |
+
- a subscripting operation with an xvalue array operand [[expr.sub]],
|
| 52 |
+
- a class member access expression designating a non-static data member
|
| 53 |
+
of non-reference type in which the object expression is an xvalue
|
| 54 |
+
[[expr.ref]], or
|
| 55 |
+
- a `.*` pointer-to-member expression in which the first operand is an
|
| 56 |
+
xvalue and the second operand is a pointer to data member
|
| 57 |
+
[[expr.mptr.oper]].
|
| 58 |
+
|
| 59 |
+
In general, the effect of this rule is that named rvalue references are
|
| 60 |
+
treated as lvalues and unnamed rvalue references to objects are treated
|
| 61 |
+
as xvalues; rvalue references to functions are treated as lvalues
|
| 62 |
+
whether named or not.
|
| 63 |
+
|
| 64 |
+
— *end note*]
|
| 65 |
+
|
| 66 |
+
[*Example 1*:
|
| 67 |
+
|
| 68 |
+
``` cpp
|
| 69 |
+
struct A {
|
| 70 |
+
int m;
|
| 71 |
+
};
|
| 72 |
+
A&& operator+(A, A);
|
| 73 |
+
A&& f();
|
| 74 |
+
|
| 75 |
+
A a;
|
| 76 |
+
A&& ar = static_cast<A&&>(a);
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
The expressions `f()`, `f().m`, `static_cast<A&&>(a)`, and `a + a` are
|
| 80 |
+
xvalues. The expression `ar` is an lvalue.
|
| 81 |
+
|
| 82 |
+
— *end example*]
|
| 83 |
+
|
| 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
|
| 105 |
+
such a context; see [[dcl.init.ref]]. — *end note*]
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
[*Note 6*: Because cv-qualifiers are removed from the type of an
|
| 108 |
+
expression of non-class type when the expression is converted to a
|
| 109 |
+
prvalue, an lvalue of type `const int` can, for example, be used where a
|
| 110 |
+
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.simple]], a prvalue shall always
|
| 125 |
+
have complete type or the `void` type; if it has a class type or
|
| 126 |
+
(possibly multi-dimensional) array of class type, that class shall not
|
| 127 |
+
be an abstract class [[class.abstract]]. A glvalue shall not have type
|
| 128 |
cv `void`.
|
| 129 |
|
| 130 |
+
[*Note 8*: A glvalue may 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 ([[expr.ass]],
|
| 139 |
+
[[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*: Unlike in C, C++ has no accesses of class
|
| 156 |
+
type. — *end note*]
|
| 157 |
+
|