Title
Defaulting a function that would be implicitly defined as deleted
Status
cd2
Section
9.5 [dcl.fct.def]
Submitter
Alisdair Meredith

Created on 2009-07-01.00:00:00 last changed 143 months ago

Messages

Date: 2009-10-15.00:00:00

[Voted into WP at October, 2009 meeting.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009):

  1. Change 9.5 [dcl.fct.def] paragraph 9 as follows:

  2. Only special member functions may be explicitly defaulted, and the implementation shall define them as if they had implicit definitions (11.4.5 [class.ctor], 11.4.7 [class.dtor], _N4750_.15.8 [class.copy]). A special member function that would be implicitly defined as deleted shall not be explicitly defaulted. A special member function that would be implicitly defined as deleted may be explicitly defaulted only on its first declaration, in which case it is defined as deleted. A special member function is user-provided if...
  3. Change 11.4.5 [class.ctor] paragraph 6 as follows:

  4. A non-user-provided default constructor for a class is implicitly defined when it is used (6.3 [basic.def.odr]) to create an object of its class type (6.7.2 [intro.object]). If the implicitly-defined default constructor is explicitly defaulted but the corresponding implicit declaration would have been deleted, the program is ill-formed. The implicitly-defined or explicitly-defaulted default constructor...
  5. Change 11.4.7 [class.dtor] paragraph 4 as follows:

  6. A program is ill-formed if the class for which a destructor is implicitly defined or explicitly defaulted has: if the implicitly-defined destructor is explicitly defaulted, but the corresponding implicit declaration would have been deleted.

    • a non-static data member of class type (or array thereof) with an inaccessible destructor, or

    • a base class with an inaccessible destructor.

  7. Change _N4750_.15.8 [class.copy] paragraph 7 as follows:

  8. ...[Note: the copy constructor is implicitly defined even if the implementation elided its use (6.7.7 [class.temporary]). —end note] A program is ill-formed if the implicitly-defined copy constructor is explicitly defaulted, but the corresponding implicit declaration would have been deleted.
  9. Change _N4750_.15.8 [class.copy] paragraph 12 as follows:

  10. A non-user-provided copy assignment operator is implicitly defined when an object of its class type is assigned a value of its class type or a value of a class type derived from its class type. A program is ill-formed if the implicitly-defined copy assignment operator is explicitly defaulted, but the corresponding implicit declaration would have been deleted.
Date: 2009-07-01.00:00:00

9.5 [dcl.fct.def] paragraph 9 says,

A special member function that would be implicitly defined as deleted shall not be explicitly defaulted.

It would be more regular (and thus useful in generic programming) if such a member function were itself simply defined as deleted rather than being made ill-formed.

History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: dr -> cd2
2009-11-08 00:00:00adminsetmessages: + msg2456
2009-11-08 00:00:00adminsetstatus: ready -> dr
2009-08-03 00:00:00adminsetmessages: + msg2163
2009-07-01 00:00:00admincreate