Created on 2013-08-09.00:00:00 last changed 28 months ago
Proposed resolution (August, 2021):
Change 11.4.6 [class.copy.assign] paragraph 6 as follows:
The implicitly-declared copy/move assignment operator for class X has the return type X&; it returns the object for which the assignment operator is invoked, that is, the object assigned to. An implicitly-declared copy/move assignment operator is an inline public member of its class.
Add the following as a new paragraph following 11.4.6 [class.copy.assign] paragraph 13:
The implicitly-defined copy assignment operator for a union X copies the object representation (6.8 [basic.types]) of X. If the source and destination of the assignment are not the same object, then for each object nested within (6.7.2 [intro.object]) the object that is the source of the copy, a corresponding object o nested within the destination is created, and the lifetime of o begins before the copy is performed.
The implicitly-defined copy/move assignment operator for a class returns the object for which the assignment operator is invoked, that is, the object assigned to.
[Note: The first point in the issue, that of the relationship between the ref-qualifier and the return type, will be referred to EWG for consideration. The draft resolution above addresses only the second point of the issue.
[Accepted as a DR at the October, 2021 meeting.]
9.5.2 [dcl.fct.def.default] paragraph 1 specifies that an explicitly-defaulted function shall
have the same declared function type (except for possibly differing ref-qualifiers and except that in the case of a copy constructor or copy assignment operator, the parameter type may be “reference to non-const T”, where T is the name of the member function's class) as if it had been implicitly declared...
This allows an example like
struct A { A& operator=(A const&) && = default; };
but forbids
struct B { B&& operator=(B const&) && = default; };
which seems backward.
In addition, 11.4.5.3 [class.copy.ctor] paragraph 22 only specifies the return value for implicitly-declared copy/move assignment operators, not for explicitly-defaulted ones.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-08-19 07:54:33 | admin | set | status: drwp -> cd6 |
2022-02-15 00:00:00 | admin | set | status: dr -> drwp |
2021-11-15 00:00:00 | admin | set | messages: + msg6574 |
2021-11-15 00:00:00 | admin | set | status: drafting -> dr |
2013-10-14 00:00:00 | admin | set | status: open -> drafting |
2013-08-09 00:00:00 | admin | create |