From Jason Turner

[basic.lval]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfv4kzi5s/{from.md → to.md} +71 -59
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
- - An *lvalue* (so called, historically, because lvalues could appear on
11
- the left-hand side of an assignment expression) designates a function
12
- or an object. If `E` is an expression of pointer type, then `*E` is an
13
- lvalue expression referring to the object or function to which `E`
14
- points. As another example, the result of calling a function whose
15
- return type is an lvalue reference is an lvalue.
16
- - An *xvalue* (an “eXpiring” value) also refers to an object, usually
17
- near the end of its lifetime (so that its resources may be moved, for
18
- example). An xvalue is the result of certain kinds of expressions
19
- involving rvalue references ([[dcl.ref]]). The result of calling a
20
- function whose return type is an rvalue reference to an object type is
21
- an xvalue ([[expr.call]]).
22
- - A *glvalue* (“generalized” lvalue) is an lvalue or an xvalue.
23
- - An *rvalue* (so called, historically, because rvalues could appear on
24
- the right-hand side of an assignment expression) is an xvalue, a
25
- temporary object ([[class.temporary]]) or subobject thereof, or a
26
- value that is not associated with an object.
27
- - A *prvalue* (“pure” rvalue) is an rvalue that is not an xvalue. The
28
- result of calling a function whose return type is not a reference is a
29
- prvalue. The value of a literal such as `12`, `7.3e5`, or `true` is
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*. The discussion
35
- of each built-in operator in Clause  [[expr]] indicates the category of
36
- the value it yields and the value categories of the operands it expects.
37
- For example, the built-in assignment operators expect that the left
38
- operand is an lvalue and that the right operand is a prvalue and yield
39
- an lvalue as the result. User-defined operators are functions, and the
40
- categories of values they expect and yield are determined by their
41
- parameter and return types.
42
-
43
- Whenever a glvalue appears in a context where a prvalue is expected, the
44
- glvalue is converted to a prvalue; see  [[conv.lval]], [[conv.array]],
45
- and  [[conv.func]]. An attempt to bind an rvalue reference to an lvalue
46
- is not such a context; see  [[dcl.init.ref]].
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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]]), prvalues shall always have
53
- complete types or the `void` type; in addition to these types, glvalues
54
- can also have incomplete types. class and array prvalues can have
55
- cv-qualified types; other prvalues always have cv-unqualified types. See
56
- Clause  [[expr]].
57
 
58
- An lvalue for an object is necessary in order to modify the object
59
- except that an rvalue of class type can also be used to modify its
60
- referent under certain circumstances. a member function called for an
61
- object ([[class.mfct]]) can modify the object.
62
 
63
- Functions cannot be modified, but pointers to functions can be
64
- modifiable.
65
 
66
- A pointer to an incomplete type can be modifiable. At some point in the
67
- program when the pointed to type is complete, the object at which the
68
- pointer points can also be modified.
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:[^30]
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` or `unsigned` `char` type.
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