<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2315</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="2315"></A><H4>2315.
  
What is the &#8220;corresponding special member&#8221; of a variant member?
</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>CD5
 &#160;&#160;&#160;

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2016-08-15<BR>


<P>[Accepted as a DR at the November, 2017 meeting.]</P>



<P>According to 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#10.1">class.copy.ctor</A>] bullet 10.1,</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>a variant member with a non-trivial corresponding constructor
and <TT>X</TT> is a union-like class,</P></LI>

</UL>

</BLOCKQUOTE>

<P>However, it is not clear from this specification how to handle an
example like:</P>

<PRE>
  struct A {
    A();
    A(const A&amp;);
  };
  union B {
    A a;
  };
</PRE>

<P>since there is no corresponding special member in <TT>A</TT>.</P>

<P><B>Proposed resolution (August, 2017):</B></P>

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

<BLOCKQUOTE>

<P>An implicitly-declared copy/move constructor is an inline public member of
its class. 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><DEL>a variant member with a non-trivial corresponding
constructor and <TT>X</TT> is a union-like class,</DEL></P></LI>

<LI><P>a potentially constructed subobject type <TT>M</TT> (or array
thereof) that cannot be copied/moved because overload resolution
(12.2 [<A href="https://wg21.link/over.match">over.match</A>]), as applied to find <TT>M</TT>'s corresponding
constructor, results in an ambiguity or a function that is deleted or
inaccessible from the defaulted constructor,</P></LI>

<LI><P><INS>a variant member whose corresponding constructor as selected
by overload resolution is non-trivial,</INS></P></LI>

<LI><P>any potentially constructed subobject of a type with a destructor
that is deleted or inaccessible from the defaulted constructor,
or,</P></LI>

<LI><P>for the copy constructor, a non-static data member of rvalue
reference type.</P></LI>

</UL>

</BLOCKQUOTE>

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