Title
Inheriting constructors and copy/move constructors
Status
c++14
Section
_N4527_.12.9 [class.inhctor]
Submitter
Jason Merrill

Created on 2012-10-10.00:00:00 last changed 122 months ago

Messages

Date: 2013-09-15.00:00:00

[Moved to DR at the September, 2013 meeting.]

Date: 2013-04-15.00:00:00

Proposed resolution (April, 2013):

Change _N4527_.12.9 [class.inhctor] paragraph 3 as follows:

For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the class where the using-declaration appears or the constructor would be a default, copy, or move constructor for that class.
Date: 2016-02-15.00:00:00

According to _N4527_.12.9 [class.inhctor] paragraph 3,

For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the class where the using-declaration appears.

It seems that this should be suppressing constructors that would be copy/move constructors in the derived class rather than copy/move constructors in the base class. For example:

  struct B;
  struct A {
    A(const A&);
    A(const B&);
    A(int);
  };

  struct B: A {
    using A::A;
  };

If B::B(const B&) is an inheriting constructor, other subobjects of B will not be copied. Also, if A::A(const A&) is not inherited, B objects cannot be constructed from an A object.

History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: drwp -> c++14
2014-03-03 00:00:00adminsetstatus: dr -> drwp
2013-10-14 00:00:00adminsetmessages: + msg4696
2013-10-14 00:00:00adminsetstatus: ready -> dr
2013-05-03 00:00:00adminsetstatus: review -> ready
2012-11-03 00:00:00adminsetmessages: + msg4087
2012-10-10 00:00:00admincreate