tmp/tmpy2ob8a4r/{from.md → to.md}
RENAMED
|
@@ -1,89 +0,0 @@
|
|
| 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 |
-
|
| 18 |
-
``` bnf
|
| 19 |
-
assignment-expression:
|
| 20 |
-
conditional-expression
|
| 21 |
-
yield-expression
|
| 22 |
-
throw-expression
|
| 23 |
-
logical-or-expression assignment-operator initializer-clause
|
| 24 |
-
```
|
| 25 |
-
|
| 26 |
-
``` bnf
|
| 27 |
-
assignment-operator: one of
|
| 28 |
-
'= *= /= %= += -= >>= <<= &= ^= |='
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
In simple assignment (`=`), the object referred to by the left operand
|
| 32 |
-
is modified [[defns.access]] by replacing its value with the result of
|
| 33 |
-
the right operand.
|
| 34 |
-
|
| 35 |
-
If the right operand is an expression, it is implicitly converted
|
| 36 |
-
[[conv]] to the cv-unqualified type of the left operand.
|
| 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;
|
| 81 |
-
z = { 1,2 }; // meaning z.operator=({1,2\)}
|
| 82 |
-
z += { 1, 2 }; // meaning z.operator+=({1,2\)}
|
| 83 |
-
int a, b;
|
| 84 |
-
a = b = { 1 }; // meaning a=b=1;
|
| 85 |
-
a = { 1 } = b; // syntax error
|
| 86 |
-
```
|
| 87 |
-
|
| 88 |
-
— *end example*]
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|