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

2024-04-18


2356. Base class copy and move constructors should not be inherited

Section: 12.2.2  [over.match.funcs]     Status: CD5     Submitter: Richard Smith     Date: 2018-02-26

[Accepted as a DR at the June, 2018 (Rapperswil) meeting.]

Base class copy and move constructors brought into a derived class via a using-declaration should not be considered by overload resolution when constructing a derived class object.

Proposed resolution, February, 2018:

Change 12.2.2 [over.match.funcs] paragraph 8 as follows:

A defaulted move special function (11.4.5.3 [class.copy.ctor]) that is defined as deleted is excluded from the set of candidate functions in all contexts. A constructor inherited from class type C (11.9.4 [class.inhctor.init]) that has a first parameter of type “reference to cv1 P” (including such a constructor instantiated from a template) is excluded from the set of candidate functions when constructing an object of type cv2 D if the argument list has exactly one argument and C is reference-related to P and P is reference-related to D. [Example:

  struct A {
    A();
    A(A &&);                        // #1
    template<typename T> A(T &&);   // #2
  };
  struct B : A {
    using A::A;
    B(const B &);                   // #3
    B(B &&) = default;              // #4, implicitly deleted

    struct X { X(X &&) = delete; } x;
  };
  extern B b1;
  B b2 = static_cast<B&&>(b1);      // calls #3: #1, #2, and #4 are not viable
  struct C { operator B&&(); };
  B b3 = C();                       // calls #3

end example]