Title
Identical inheriting constructors via default arguments
Status
cd4
Section
_N4527_.12.9 [class.inhctor]
Submitter
Richard Smith

Created on 2013-03-18.00:00:00 last changed 49 months ago

Messages

Date: 2014-07-07.00:00:00

Additional note, June, 2014:

See issue 1941 for an alternative approach to this problem.

Date: 2013-04-15.00:00:00

Notes from the April, 2013 meeting:

CWG agreed with the direction of defining such constructors as deleted.

Date: 2015-10-15.00:00:00

[Adopted at the October, 2015 meeting as P0136R1.]

For an example like

  struct A {
    constexpr A(int, float = 0);
    explicit A(int, int = 0);
    A(int, int, int = 0) = delete;
  };

  struct B : A {
    using A::A;
  };

it is not clear from _N4527_.12.9 [class.inhctor] what should happen: is B::B(int) constexpr and/or explicit? Is B::B(int, int) explicit and/or deleted? Although the rationale given in the note in paragraph 7,

If two using-declarations declare inheriting constructors with the same signatures, the program is ill-formed (11.4 [class.mem], _N4868_.12.2 [over.load]), because an implicitly-declared constructor introduced by the first using-declaration is not a user-declared constructor and thus does not preclude another declaration of a constructor with the same signature by a subsequent using-declaration.

might be thought to apply, paragraph 1 talks about a set of candidate constructors based on their parameter types, so presumably such a set would contain only a single declaration of A::A(int) and one for A::A(int, int). The constructor characteristics of that declaration, however, are not specified.

One possibility might be to declare such a constructor, resulting from the transformation of more than one base class constrctor, to be deleted, so there would be an error only if it were used.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: dr -> cd4
2015-11-10 00:00:00adminsetstatus: drafting -> dr
2014-07-07 00:00:00adminsetmessages: + msg5094
2013-05-03 00:00:00adminsetmessages: + msg4345
2013-03-18 00:00:00admincreate