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

2024-04-05


1487. When are inheriting constructors declared?

Section: _N4527_.12.9  [class.inhctor]     Status: CD3     Submitter: Richard Smith     Date: 2012-03-27

[Moved to DR at the April, 2013 meeting.]

According to _N4527_.12.9 [class.inhctor] paragraph 3,

For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the class where the using-declaration appears.

It is not clear whether that determination is intended to include constructors declared after the point of the using-declaration or not.

Proposed resolution (February, 2013):

  1. Change 11.4 [class.mem] paragraph 2 as follows:

  2. A class is considered a completely-defined object type (6.8 [basic.types]) (or complete type) at the closing } of the class-specifier. Within the class member-specification, the class is regarded as complete within function bodies, default arguments, using-declarations introducing inheriting constructors (_N4527_.12.9 [class.inhctor]), and brace-or-equal-initializers for non-static data members (including such things in nested classes). Otherwise it is regarded as incomplete within its own class member-specification.
  3. Change 11.4.4 [special] paragraph 1 as follows:

  4. ...See 11.4.5 [class.ctor], 11.4.7 [class.dtor] and 11.4.5.3 [class.copy.ctor]. —end note] An implicitly-declared special member function is declared at the closing } of the class-specifier. Programs shall not define implicitly-declared special member functions.
  5. Change _N4527_.12.9 [class.inhctor] paragraph 3 as follows:

  6. For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the complete class where the using-declaration appears. Similarly, for each constructor template in the candidate set of inherited constructors, a constructor template is implicitly declared with the same constructor characteristics unless there is an equivalent user-declared constructor template (13.7.7.2 [temp.over.link]) in the complete class where the using-declaration appears. [Note: Default arguments are not inherited. An exception-specification is implied as specified in 14.5 [except.spec]. —end note]

Additional note (January, 2013):

A question has been raised as to whether it is necessary to prohibit inheriting constructors from base classes that are also enclosing classes when the derived class is defined outside the member-specification of the enclosing class. This issue has been returned to "review" status to allow discussion of this question.

Additional note (February, 2013):

It was observed that it is not permitted to derive from an incomplete class, which prevents the problem intended to be addressed by the prohibition of inheriting constructors from an enclosing class without disallowing such usage when the nested class is defined outside its enclosing class. That restriction has been removed from the proposed resolution.