Title
using-declarations vs copy assignment operators
Status
nad
Section
11.4.6 [class.copy.assign]
Submitter
Mike Miller

Created on 2019-05-29.00:00:00 last changed 47 months ago

Messages

Date: 2019-06-15.00:00:00

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.
Date: 2022-11-20.07:54:16

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=?

History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6305
2019-05-29 00:00:00admincreate