tmp/tmpfv4kzi5s/{from.md → to.md}
RENAMED
|
@@ -5,82 +5,94 @@ Expressions are categorized according to the taxonomy in Figure
|
|
| 5 |
|
| 6 |
<a id="fig:categories"></a>
|
| 7 |
|
| 8 |
![Expression category taxonomy \[fig:categories\]](images/valuecategories.svg)
|
| 9 |
|
| 10 |
-
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
also a prvalue.
|
| 31 |
|
| 32 |
Every expression belongs to exactly one of the fundamental
|
| 33 |
classifications in this taxonomy: lvalue, xvalue, or prvalue. This
|
| 34 |
-
property of an expression is called its *value category*.
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
The discussion of reference initialization in [[dcl.init.ref]] and of
|
| 49 |
temporaries in [[class.temporary]] indicates the behavior of lvalues
|
| 50 |
and rvalues in other significant contexts.
|
| 51 |
|
| 52 |
-
Unless otherwise indicated ([[expr.call]]),
|
| 53 |
-
complete
|
| 54 |
-
|
| 55 |
-
cv-qualified types; other prvalues always have cv-unqualified types. See
|
| 56 |
-
Clause [[expr]].
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
object ([[class.mfct]]) can modify the object.
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
The referent of a `const`-qualified expression shall not be modified
|
| 71 |
-
(through that expression), except that if it is of class type and has a
|
| 72 |
-
`mutable` component, that component can be modified ([[dcl.type.cv]]).
|
| 73 |
-
|
| 74 |
-
If an expression can be used to modify the object to which it refers,
|
| 75 |
-
the expression is called *modifiable*. A program that attempts to modify
|
| 76 |
-
an object through a nonmodifiable lvalue or rvalue expression is
|
| 77 |
-
ill-formed.
|
| 78 |
|
| 79 |
If a program attempts to access the stored value of an object through a
|
| 80 |
glvalue of other than one of the following types the behavior is
|
| 81 |
-
undefined:[^
|
| 82 |
|
| 83 |
- the dynamic type of the object,
|
| 84 |
- a cv-qualified version of the dynamic type of the object,
|
| 85 |
- a type similar (as defined in [[conv.qual]]) to the dynamic type of
|
| 86 |
the object,
|
|
@@ -92,7 +104,7 @@ undefined:[^30]
|
|
| 92 |
types among its elements or non-static data members (including,
|
| 93 |
recursively, an element or non-static data member of a subaggregate or
|
| 94 |
contained union),
|
| 95 |
- a type that is a (possibly cv-qualified) base class type of the
|
| 96 |
dynamic type of the object,
|
| 97 |
-
- a `char`
|
| 98 |
|
|
|
|
| 5 |
|
| 6 |
<a id="fig:categories"></a>
|
| 7 |
|
| 8 |
![Expression category taxonomy \[fig:categories\]](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 the operand of an operator, as
|
| 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). \[*Example 1*: Certain kinds of expressions involving
|
| 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 |
+
[*Note 1*: Historically, lvalues and rvalues were so-called because
|
| 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 |
Every expression belongs to exactly one of the fundamental
|
| 32 |
classifications in this taxonomy: lvalue, xvalue, or prvalue. This
|
| 33 |
+
property of an expression is called its *value category*.
|
| 34 |
+
|
| 35 |
+
[*Note 2*: The discussion of each built-in operator in Clause [[expr]]
|
| 36 |
+
indicates the category of the value it yields and the value categories
|
| 37 |
+
of the operands it expects. For example, the built-in assignment
|
| 38 |
+
operators expect that the left operand is an lvalue and that the right
|
| 39 |
+
operand is a prvalue and yield an lvalue as the result. User-defined
|
| 40 |
+
operators are functions, and the categories of values they expect and
|
| 41 |
+
yield are determined by their parameter and return types. — *end note*]
|
| 42 |
+
|
| 43 |
+
The *result* of a prvalue is the value that the expression stores into
|
| 44 |
+
its context. A prvalue whose result is the value *V* is sometimes said
|
| 45 |
+
to have or name the value *V*. The *result object* of a prvalue is the
|
| 46 |
+
object initialized by the prvalue; a prvalue that is used to compute the
|
| 47 |
+
value of an operand of an operator or that has type cv `void` has no
|
| 48 |
+
result object.
|
| 49 |
+
|
| 50 |
+
[*Note 3*: Except when the prvalue is the operand of a
|
| 51 |
+
*decltype-specifier*, a prvalue of class or array type always has a
|
| 52 |
+
result object. For a discarded prvalue, a temporary object is
|
| 53 |
+
materialized; see Clause [[expr]]. — *end note*]
|
| 54 |
+
|
| 55 |
+
The *result* of a glvalue is the entity denoted by the expression.
|
| 56 |
+
|
| 57 |
+
[*Note 4*: Whenever a glvalue appears in a context where a prvalue is
|
| 58 |
+
expected, the glvalue is converted to a prvalue; see [[conv.lval]],
|
| 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 5*: There are no prvalue bit-fields; if a bit-field is converted
|
| 64 |
+
to a prvalue ([[conv.lval]]), a prvalue of the type of the bit-field is
|
| 65 |
+
created, which might then be promoted ([[conv.prom]]). — *end note*]
|
| 66 |
+
|
| 67 |
+
[*Note 6*: Whenever a prvalue appears in a context where a glvalue is
|
| 68 |
+
expected, the prvalue is converted to an xvalue; see
|
| 69 |
+
[[conv.rval]]. — *end note*]
|
| 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 ([[expr.call]]), a prvalue shall always have
|
| 76 |
+
complete type or the `void` type. A glvalue shall not have type
|
| 77 |
+
cv `void`.
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
[*Note 7*: A glvalue may have complete or incomplete non-`void` type.
|
| 80 |
+
Class and array prvalues can have cv-qualified types; other prvalues
|
| 81 |
+
always have cv-unqualified types. See Clause [[expr]]. — *end note*]
|
|
|
|
| 82 |
|
| 83 |
+
An lvalue is *modifiable* unless its type is const-qualified or is a
|
| 84 |
+
function type.
|
| 85 |
|
| 86 |
+
[*Note 8*: A program that attempts to modify an object through a
|
| 87 |
+
nonmodifiable lvalue expression or through an rvalue expression is
|
| 88 |
+
ill-formed ([[expr.ass]], [[expr.post.incr]],
|
| 89 |
+
[[expr.pre.incr]]). — *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
If a program attempts to access the stored value of an object through a
|
| 92 |
glvalue of other than one of the following types the behavior is
|
| 93 |
+
undefined:[^31]
|
| 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,
|
|
|
|
| 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 |
|