7 Expressions [expr]

7.6 Compound expressions [expr.compound]

7.6.19 Assignment and compound assignment operators [expr.ass]

The assignment operator (=) and the compound assignment operators all group right-to-left.
All require a modifiable lvalue as their left operand; their result is an lvalue referring to the left operand.
The result in all cases is a bit-field if the left operand is a bit-field.
In all cases, the assignment is sequenced after the value computation of the right and left operands, and before the value computation of the assignment expression.
The right operand is sequenced before the left operand.
With respect to an indeterminately-sequenced function call, the operation of a compound assignment is a single evaluation.
Note
:
Therefore, a function call shall not intervene between the lvalue-to-rvalue conversion and the side effect associated with any single compound assignment operator.
— end note
 ]
assignment-expression:
	conditional-expression
	yield-expression
	throw-expression
	logical-or-expression assignment-operator initializer-clause
assignment-operator: one of
	=  *=  /=  %=   +=  -=  >>=  <<=  &=  ^=  |=
In simple assignment (=), the object referred to by the left operand is modified by replacing its value with the result of the right operand.
The expression is implicitly converted ([conv]) to the cv-unqualified type of the left operand.
When the left operand of an assignment operator is a bit-field that cannot represent the value of the expression, the resulting value of the bit-field is implementation-defined.
A simple assignment whose left operand is of a volatile-qualified type is deprecated ([depr.volatile.type]) unless the assignment is either a discarded-value expression or appears in an unevaluated context.
The behavior of an expression of the form E1 op= E2 is equivalent to E1 = E1 op E2 except that E1 is evaluated only once.
Such expressions are deprecated if E1 has volatile-qualified type; see [depr.volatile.type].
For += and -=, E1 shall either have arithmetic type or be a pointer to a possibly cv-qualified completely-defined object type.
In all other cases, E1 shall have arithmetic type.
If the value being stored in an object is read via another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall have the same type, otherwise the behavior is undefined.
Note
:
This restriction applies to the relationship between the left and right sides of the assignment operation; it is not a statement about how the target of the assignment may be aliased in general.
— end note
 ]
A braced-init-list may appear on the right-hand side of
  • an assignment to a scalar, in which case the initializer list shall have at most a single element. The meaning of x = {v}, where T is the scalar type of the expression x, is that of x = T{v}. The meaning of x = {} is x = T{}.
  • an assignment to an object of class type, in which case the initializer list is passed as the argument to the assignment operator function selected by overload resolution ([over.ass], [over.match]).
Example
:
complex<double> z;
z = { 1,2 };        // meaning z.operator=({1,2})
z += { 1, 2 };      // meaning z.operator+=({1,2})
int a, b;
a = b = { 1 };      // meaning a=b=1;
a = { 1 } = b;      // syntax error
— end example
 ]