From Jason Turner

[expr.ass]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpg4xz9751/{from.md → to.md} +23 -20
tmp/tmpg4xz9751/{from.md → to.md} RENAMED
@@ -1,16 +1,17 @@
1
  ### Assignment and compound assignment operators <a id="expr.ass">[[expr.ass]]</a>
2
 
3
  The assignment operator (`=`) and the compound assignment operators all
4
  group right-to-left. All require a modifiable lvalue as their left
5
- operand; their result is an lvalue referring to the left operand. The
6
- result in all cases is a bit-field if the left operand is a bit-field.
7
- In all cases, the assignment is sequenced after the value computation of
8
- the right and left operands, and before the value computation of the
9
- assignment expression. The right operand is sequenced before the left
10
- operand. With respect to an indeterminately-sequenced function call, the
11
- operation of a compound assignment is a single evaluation.
 
12
 
13
  [*Note 1*: Therefore, a function call cannot intervene between the
14
  lvalue-to-rvalue conversion and the side effect associated with any
15
  single compound assignment operator. — *end note*]
16
 
@@ -36,42 +37,44 @@ If the right operand is an expression, it is implicitly converted
36
 
37
  When the left operand of an assignment operator is a bit-field that
38
  cannot represent the value of the expression, the resulting value of the
39
  bit-field is *implementation-defined*.
40
 
41
- A simple assignment whose left operand is of a volatile-qualified type
42
- is deprecated [[depr.volatile.type]] unless the (possibly parenthesized)
43
- assignment is a discarded-value expression or an unevaluated operand.
 
44
 
45
  The behavior of an expression of the form `E1 op= E2` is equivalent to
46
- `E1 = E1 op E2` except that `E1` is evaluated only once. Such
47
- expressions are deprecated if `E1` has volatile-qualified type; see 
48
- [[depr.volatile.type]]. For `+=` and `-=`, `E1` shall either have
49
- arithmetic type or be a pointer to a possibly cv-qualified
50
- completely-defined object type. In all other cases, `E1` shall have
51
- arithmetic type.
 
 
52
 
53
  If the value being stored in an object is read via another object that
54
  overlaps in any way the storage of the first object, then the overlap
55
  shall be exact and the two objects shall have the same type, otherwise
56
  the behavior is undefined.
57
 
58
- [*Note 2*: This restriction applies to the relationship between the
59
  left and right sides of the assignment operation; it is not a statement
60
- about how the target of the assignment may be aliased in general. See 
61
  [[basic.lval]]. — *end note*]
62
 
63
  A *braced-init-list* may appear on the right-hand side of
64
 
65
  - an assignment to a scalar, in which case the initializer list shall
66
  have at most a single element. The meaning of `x = {v}`, where `T` is
67
  the scalar type of the expression `x`, is that of `x = T{v}`. The
68
  meaning of `x = {}` is `x = T{}`.
69
  - an assignment to an object of class type, in which case the
70
  initializer list is passed as the argument to the assignment operator
71
- function selected by overload resolution ([[over.ass]],
72
- [[over.match]]).
73
 
74
  [*Example 1*:
75
 
76
  ``` cpp
77
  complex<double> z;
 
1
  ### Assignment and compound assignment operators <a id="expr.ass">[[expr.ass]]</a>
2
 
3
  The assignment operator (`=`) and the compound assignment operators all
4
  group right-to-left. All require a modifiable lvalue as their left
5
+ operand; their result is an lvalue of the type of the left operand,
6
+ referring to the left operand. The result in all cases is a bit-field if
7
+ the left operand is a bit-field. In all cases, the assignment is
8
+ sequenced after the value computation of the right and left operands,
9
+ and before the value computation of the assignment expression. The right
10
+ operand is sequenced before the left operand. With respect to an
11
+ indeterminately-sequenced function call, the operation of a compound
12
+ assignment is a single evaluation.
13
 
14
  [*Note 1*: Therefore, a function call cannot intervene between the
15
  lvalue-to-rvalue conversion and the side effect associated with any
16
  single compound assignment operator. — *end note*]
17
 
 
37
 
38
  When the left operand of an assignment operator is a bit-field that
39
  cannot represent the value of the expression, the resulting value of the
40
  bit-field is *implementation-defined*.
41
 
42
+ An assignment whose left operand is of a volatile-qualified type is
43
+ deprecated [[depr.volatile.type]] unless the (possibly parenthesized)
44
+ assignment is a discarded-value expression or an unevaluated operand
45
+ [[term.unevaluated.operand]].
46
 
47
  The behavior of an expression of the form `E1 op= E2` is equivalent to
48
+ `E1 = E1 op E2` except that `E1` is evaluated only once.
49
+
50
+ [*Note 2*: The object designated by `E1` is accessed
51
+ twice. *end note*]
52
+
53
+ For `+=` and `-=`, `E1` shall either have arithmetic type or be a
54
+ pointer to a possibly cv-qualified completely-defined object type. In
55
+ all other cases, `E1` shall have arithmetic type.
56
 
57
  If the value being stored in an object is read via another object that
58
  overlaps in any way the storage of the first object, then the overlap
59
  shall be exact and the two objects shall have the same type, otherwise
60
  the behavior is undefined.
61
 
62
+ [*Note 3*: This restriction applies to the relationship between the
63
  left and right sides of the assignment operation; it is not a statement
64
+ about how the target of the assignment can be aliased in general. See 
65
  [[basic.lval]]. — *end note*]
66
 
67
  A *braced-init-list* may appear on the right-hand side of
68
 
69
  - an assignment to a scalar, in which case the initializer list shall
70
  have at most a single element. The meaning of `x = {v}`, where `T` is
71
  the scalar type of the expression `x`, is that of `x = T{v}`. The
72
  meaning of `x = {}` is `x = T{}`.
73
  - an assignment to an object of class type, in which case the
74
  initializer list is passed as the argument to the assignment operator
75
+ function selected by overload resolution [[over.ass]], [[over.match]].
 
76
 
77
  [*Example 1*:
78
 
79
  ``` cpp
80
  complex<double> z;