Title
Implicit copy function if subobject has none?
Status
c++11
Section
11.4.5.3 [class.copy.ctor]
Submitter
Jason Merrill

Created on 2010-06-22.00:00:00 last changed 131 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

Date: 2010-11-15.00:00:00

Notes from the November, 2010 meeting:

The consensus of the CWG was to change the behavior so that all classes have a declaration of a copy constructor, but that it is defined as deleted in the cases where the declaration is omitted by the current rules.

Date: 2010-06-22.00:00:00

It seems odd to have an implicitly declared copy constructor (and the same for the copy assignment operator) if one of the subobjects does not have one. For example,

    struct A {
       A();
       A(A&&);
    };

    struct B: A { };

    B b;
    B b2(b); // error when implicitly defining B(B&), should not be declared

If we don't declare it in that case, we need to decide what happens if one base has only a move constructor and another has only a copy constructor.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3370
2011-04-10 00:00:00adminsetstatus: drafting -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3125
2010-11-29 00:00:00adminsetstatus: open -> drafting
2010-06-22 00:00:00admincreate