<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 928</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="928"></A><H4>928.
  
Defaulting a function that would be implicitly defined as deleted
</H4>
<B>Section: </B>9.6&#160; [<A href="https://wg21.link/dcl.fct.def">dcl.fct.def</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>1 July, 2009<BR>


<P>[Voted into WP at October, 2009 meeting.]</P>



<P>9.6 [<A href="https://wg21.link/dcl.fct.def#9">dcl.fct.def</A>] paragraph 9 says,</P>

<BLOCKQUOTE>

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

</BLOCKQUOTE>

<P>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.</P>

<P><B>Proposed resolution (July, 2009):</B></P>

<OL>
<LI><P>Change 9.6 [<A href="https://wg21.link/dcl.fct.def#9">dcl.fct.def</A>] paragraph 9 as follows:</P></LI>

<BLOCKQUOTE>

Only special member functions may be explicitly defaulted, and the
implementation shall define them as if they had implicit definitions
(11.4.5 [<A href="https://wg21.link/class.ctor">class.ctor</A>], 11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>], 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor">class.copy.ctor</A>]). <DEL>A special member function that would be implicitly
defined as deleted shall not be explicitly defaulted.</DEL> <INS>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.</INS> A special member function is
user-provided if...

</BLOCKQUOTE>

<LI><P>Change 11.4.5 [<A href="https://wg21.link/class.ctor#6">class.ctor</A>] paragraph 6 as follows:</P></LI>

<BLOCKQUOTE>

A non-user-provided default constructor for a class is implicitly
defined when it is used (6.3 [<A href="https://wg21.link/basic.def.odr">basic.def.odr</A>]) to create an object
of its class type (6.8.2 [<A href="https://wg21.link/intro.object">intro.object</A>]).  <DEL>If the
implicitly-defined default constructor is explicitly defaulted but the
corresponding implicit declaration would have been deleted, the
program is ill-formed.</DEL> The implicitly-defined or
explicitly-defaulted default constructor...

</BLOCKQUOTE>

<LI><P>Change 11.4.7 [<A href="https://wg21.link/class.dtor#4">class.dtor</A>] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

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

<UL>

<LI><P>a non-static data member of class type (or array thereof) with an inaccessible destructor, or</P></LI>

<LI><P>a base class with an inaccessible destructor.</P></LI>

</UL>

</BLOCKQUOTE>

<LI><P>Change 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#7">class.copy.ctor</A>] paragraph 7 as follows:</P></LI>

<BLOCKQUOTE>

...[<I>Note:</I> the copy constructor is implicitly defined even if
the implementation elided its use (6.8.7 [<A href="https://wg21.link/class.temporary">class.temporary</A>]). &#8212;<I>end note</I>] <DEL>A program is ill-formed if
the implicitly-defined copy constructor is explicitly defaulted, but
the corresponding implicit declaration would have been deleted.</DEL>

</BLOCKQUOTE>

<LI><P>Change 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#12">class.copy.ctor</A>] paragraph 12 as follows:</P></LI>

<BLOCKQUOTE>

A non-user-provided copy assignment operator is <I>implicitly defined</I>
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. <DEL>A program is
ill-formed if the implicitly-defined copy assignment operator is
explicitly defaulted, but the corresponding implicit declaration would
have been deleted.</DEL>

</BLOCKQUOTE>

</OL>

<BR><BR>
</BODY>
</HTML>
