This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 111. See for the official list.


1645. Identical inheriting constructors via default arguments

Section: _N4527_.12.9  [class.inhctor]     Status: CD4     Submitter: Richard Smith     Date: 2013-03-18

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

Notes from the April, 2013 meeting:

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

Additional note, June, 2014:

See issue 1941 for an alternative approach to this problem.