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


194. Identifying constructors

Section: 11.4.5  [class.ctor]     Status: TC1     Submitter: Jamie Schmeiser     Date: 11 Jan 2000

According to 11.4.5 [class.ctor] paragraph 1, the syntax used in declaring a constructor allows at most one function-specifier. It is thus not permitted to declare a constructor both inline and explicit. This seems overly restrictive.

On a related note, there doesn't seem to be any explicit prohibition against member functions with the same name as the class. (Such a prohibition might reasonably be expected to occur in 11.4 [class.mem] paragraph 13, but member functions are not listed there.)

One possible interpretation would be that such member functions would violate the restrictions in 6.4.7 [basic.scope.class] paragraph 1, because the class name would refer to the class at some points in the class scope and to the member function at others. However, this seems a bit tenuous. Is an explicit prohibition needed?

(See also issue 147.)

Proposed resolution (10/00):

  1. Add to 11.4 [class.mem] paragraph 13

    • every member function of class T [Note: this restriction does not apply to constructors, which do not have names (11.4.5 [class.ctor]). ];

    immediately following the line

    • every data member of class T;
  2. Change 11.4.5 [class.ctor] paragraph 1 from

    A special declarator syntax using an optional function-specifier (9.2.3 [dcl.fct.spec])...

    to

    A special declarator syntax using an optional sequence of function-specifiers (9.2.3 [dcl.fct.spec])...