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

2024-03-20


1567. Inheriting constructors and copy/move constructors

Section: _N4527_.12.9  [class.inhctor]     Status: C++14     Submitter: Jason Merrill     Date: 2012-10-10

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

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.

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.