<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2477</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="2477"></A><H4>2477.
  
Defaulted vs deleted copy constructors/assignment operators
</H4>
<B>Section: </B>11.4.5.3&#160; [<A href="https://wg21.link/class.copy.ctor">class.copy.ctor</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrew Rogers
 &#160;&#160;&#160;

 <B>Date: </B>2021-02-04<BR>


<P>[Accepted as a DR at the June, 2021 meeting.]</P>

<P>According to 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#6">class.copy.ctor</A>] paragraph 6,</P>

<BLOCKQUOTE>

If the class definition does not explicitly declare a copy
constructor, a non-explicit one is
declared <I>implicitly</I>.  If the class definition
declares a move constructor or move assignment operator, the
implicitly declared copy constructor is defined as deleted;
otherwise, it is defined as defaulted
(9.6 [<A href="https://wg21.link/dcl.fct.def">dcl.fct.def</A>]).

</BLOCKQUOTE>

<P>However, this rule is contradicted by paragraph 10, which
lists a number of other reasons why a defaulted copy
constructor will be defined as deleted, rather than being
&#8220;defined as defaulted,&#8221; as required by paragraph
6:</P>

<BLOCKQUOTE>

<P>A defaulted copy/move constructor for a class <TT>X</TT>
is defined as deleted (9.6.3 [<A href="https://wg21.link/dcl.fct.def.delete">dcl.fct.def.delete</A>])
if <TT>X</TT> has:</P>

<UL><LI><P>...</P></LI></UL>

<P>A similar contradiction exists for copy assignment
operators in 11.4.6 [<A href="https://wg21.link/class.copy.assign">class.copy.assign</A>] paragraphs 2
and 7.</P>

</BLOCKQUOTE>

<P><B>Proposed resolution (April, 2021):</B></P>

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

<BLOCKQUOTE>

If the class definition does not explicitly declare a copy
constructor, a non-explicit one is
declared <I>implicitly</I>.  If the class definition
declares a move constructor or move assignment operator, the
implicitly declared copy constructor is defined as deleted;
otherwise, it is <DEL>defined as</DEL> defaulted
(9.6 [<A href="https://wg21.link/dcl.fct.def">dcl.fct.def</A>]). The latter case is deprecated if
the class has a user-declared copy assignment operator or a
user-declared destructor (D.6 [<A href="https://wg21.link/depr.impldec">depr.impldec</A>]).

</BLOCKQUOTE>

<LI><P>Change 11.4.6 [<A href="https://wg21.link/class.copy.assign#2">class.copy.assign</A>] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

If the class definition does not explicitly declare a copy
assignment operator, one is declared <I>implicitly</I>.  If
the class definition declares a move constructor or move
assignment operator, the implicitly declared copy assignment
operator is defined as deleted; otherwise, it
is <DEL>defined as</DEL> defaulted
(9.6 [<A href="https://wg21.link/dcl.fct.def">dcl.fct.def</A>]). The latter case is deprecated if
the class has a user-declared copy constructor or a
user-declared destructor (D.9). The implicitly-declared...

</BLOCKQUOTE>

</OL>

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