Title
Base class copy and move constructors should not be inherited
Status
cd5
Section
12.2.2 [over.match.funcs]
Submitter
Richard Smith

Created on 2018-02-26.00:00:00 last changed 48 months ago

Messages

Date: 2022-02-18.07:47:23

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]

Date: 2018-06-15.00:00:00

[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.

History
Date User Action Args
2020-12-15 00:00:00adminsetstatus: tentatively ready -> cd5
2018-02-27 00:00:00adminsetmessages: + msg5870
2018-02-26 00:00:00admincreate