Title
Adding new special member functions to a class via default arguments
Status
c++14
Section
11.4.5.3 [class.copy.ctor]
Submitter
Sean Hunt

Created on 2011-08-16.00:00:00 last changed 121 months ago

Messages

Date: 2014-02-15.00:00:00

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

Date: 2013-09-15.00:00:00

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.

Date: 2013-09-15.00:00:00

Notes from the September, 2013 meeting:

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

Date: 2013-10-14.00:00:00
N3690 comment CA 29

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.

History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: dr -> c++14
2014-03-03 00:00:00adminsetmessages: + msg4958
2014-03-03 00:00:00adminsetstatus: ready -> dr
2013-10-14 00:00:00adminsetmessages: + msg4597
2013-10-14 00:00:00adminsetmessages: + msg4596
2013-10-14 00:00:00adminsetstatus: drafting -> ready
2011-08-16 00:00:00admincreate