Title
When is a copy/move assignment operator implicitly defined?
Status
c++11
Section
11.4.6 [class.copy.assign]
Submitter
Mike Miller

Created on 2010-03-24.00:00:00 last changed 123 months ago

Messages

Date: 2010-11-15.00:00:00

[Voted into the WP at the November, 2010 meeting.]

Date: 2010-08-15.00:00:00

Proposed resolution (August, 2010):

This issue is resolved by the resolution of issue 1051.

Date: 2022-02-18.07:47:23
N3092 comment US 64

According to 11.4.5.3 [class.copy.ctor] paragraph 28,

A copy/move assignment operator that is defaulted and not defined as deleted is implicitly defined when an object of its class type is assigned a value of its class type or a value of a class type derived from its class type or when it is explicitly defaulted after its first declaration.

This sounds as if any assignment to a class object, regardless of whether it is a copy or a move assignment, defines both the copy and move operators. Presumably an assignment should only define the assignment operator chosen by overload resolution for the operation. (Compare the corresponding wording in paragraph 14 for the copy/move constructors: “...implicitly defined if it is used to initialize an object of its class type...”)

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: dr -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3189
2010-11-29 00:00:00adminsetstatus: tentatively ready -> dr
2010-10-18 00:00:00adminsetstatus: ready -> tentatively ready
2010-08-23 00:00:00adminsetmessages: + msg2797
2010-08-23 00:00:00adminsetstatus: open -> ready
2010-03-24 00:00:00admincreate