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

2024-10-26


1344. Adding new special member functions to a class via default arguments

Section: 11.4.5.3  [class.copy.ctor]     Status: C++14     Submitter: Sean Hunt     Date: 2011-08-16

N3690 comment CA 29

[Moved to DR at the February, 2014 meeting.]

If default arguments added in the out-of-class definition of a constructor make it a special member function, this can affect the overload resolution and thus the implicit exception specification and the triviality of an implicitly-declared special member function in a derived class.

See also issue 1496, which should also be addressed by the resolution of this issue.

Notes from the September, 2013 meeting:

It was decided to resolve this issue separately from issue 1496, which is now decoupled from this issue.

Proposed resolution (September, 2013):

  1. Change 9.3.4.7 [dcl.fct.default] paragraph 6 as follows:

  2. Except for member functions of class templates, the default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition; the program is ill-formed if a default constructor (11.4.5 [class.ctor]), copy or move constructor, or copy or move assignment operator (11.4.5.3 [class.copy.ctor]) is so declared. Default arguments for a member function of a class template shall be specified on the initial declaration of the member function within the class template. [Example:...
  3. Delete the following from 11.4.5.3 [class.copy.ctor] paragraph 7:

  4. ...The latter case is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. Thus, for the class definition

      struct X {
        X(const X&, int);
      };
    

    a copy constructor is implicitly-declared. If the user-declared constructor is later defined as

      X::X(const X& x, int i =0) { /* ... */ }
    

    then any use of X's copy constructor is ill-formed because of the ambiguity; no diagnostic is required.