This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


221. Must compound assignment operators be member functions?

Section: 12.4.3.2  [over.ass]     Status: CD1     Submitter: Jim Hyslop     Date: 3 Apr 2000

[Moved to DR at 4/01 meeting.]

Is the intent of 12.4.3.2 [over.ass] paragraph 1 that all assignment operators be non-static member functions (including operator+=, operator*=, etc.) or only simple assignment operators (operator=)?

Notes from 04/00 meeting:

Nearly all references to "assignment operator" in the IS mean operator= and not the compound assignment operators. The ARM was specific that this restriction applied only to operator=. If it did apply to compound assignment operators, it would be impossible to overload these operators for bool operands.

Proposed resolution (04/01):

  1. Change the title of 7.6.19 [expr.ass] from "Assignment operators" to "Assignment and compound assignment operators."

  2. Change the first sentence of 7.6.19 [expr.ass] paragraph 1 from

    There are several assignment operators, all of which group right-to-left. All require a modifiable lvalue as their left operand, and the type of an assignment expression is that of its left operand. The result of the assignment operation is the value stored in the left operand after the assignment has taken place; the result is an lvalue.

    to

    The assignment operator (=) and the compound assignment operators all group right-to-left. All require a modifiable lvalue as their left operand and return an lvalue with the type and value of the left operand after the assignment has taken place.

Additional note (10/00): Paragraphs 2-6 of 7.6.19 [expr.ass] should all be understood to apply to simple assignment only and not to compound assignment operators.