<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1776</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="1776"></A><H4>1776.
  
Replacement of class objects containing reference members
</H4>
<B>Section: </B>6.8.4&#160; [<A href="https://wg21.link/basic.life">basic.life</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Finland
 &#160;&#160;&#160;

 <B>Date: </B>2013-09-24<BR><BR>


<P>[Adopted at the June, 2016 meeting as document P0137R1.]</P>

<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3903.html#FI15">N3690 comment
  FI&#160;15<BR></A>

<p>The rules given in 6.8.4 [<A href="https://wg21.link/basic.life#7">basic.life</A>] paragraph 7 for when
an object's lifetime can be ended and a new object created in its
storage include the following restriction:</p>

<BLOCKQUOTE>

the type of the original object is not const-qualified, and, if a class
type, does not contain any non-static data member whose type is
const-qualified or a reference type

</BLOCKQUOTE>

<P>The intent of this restriction is to permit optimizers to rely upon
the original values of <TT>const</TT> and reference members in their
analysis of subsequent code.  However, this makes it difficult to
implement certain desirable functionality such as
<TT>optional&lt;T&gt;</TT>; see
<A HREF="https://groups.google.com/a/isocpp.org/forum/#!msg/std-proposals/93ebFsxCjvQ/myxPG6o_9pkJ">this discussion</A>
for more details.</P>

<P>This rule should be reconsidered, at least as far as it applies to
unions.  If it is decided to keep the rule, acceptable programming
techniques for writing safe code when replacing such objects should
be outlined in a note.</P>

<P>(See also <A HREF="1404.html">issue 1404</A>, which will become
moot if the restriction is lifted.)</P>



<P><B>Notes from the October, 2015 meeting:</B></P>

<P>See also paper P0137 and <A HREF="2182.html">issue 2182</A>.</P>

<P><B>Notes from the February, 2017 meeting.</B></P>

<P>The resolution of this issue also resolves issues
<A HREF="636.html">636</A> and <A HREF="2151.html">2151</A>.</P>

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