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

2024-11-11


2415. using-declarations vs copy assignment operators

Section: 11.4.6  [class.copy.assign]     Status: NAD     Submitter: Mike Miller     Date: 2019-05-29

It is not clear whether a using-declaration naming an assignment operator from a base class can be considered to declare a copy assignment operator or not. For example:

  struct A;

  struct B {
    constexpr A & operator= (const A &);
  };

  struct A : B {
    using B::operator=;
  } a { a = a };

There is implementation divergence on the treatment of this code: should the using-declaration suppress or conflict with the implicit declaration of A::operator=?

Rationale (June, 2019):

This question is addressed explicitly by 9.9 [namespace.udecl] paragraph 4:

If a constructor or assignment operator brought from a base class into a derived class has the signature of a copy/move constructor or assignment operator for the derived class (11.4.5.3 [class.copy.ctor], 11.4.6 [class.copy.assign]), the using-declaration does not by itself suppress the implicit declaration of the derived class member; the member from the base class is hidden or overridden by the implicitly-declared copy/move constructor or assignment operator of the derived class, as described below.