<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3141: CopyConstructible doesn't preserve source values</title>
<meta property="og:title" content="Issue 3141: CopyConstructible doesn't preserve source values">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3141.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++20">C++20</a> status.</em></p>
<h3 id="3141"><a href="lwg-defects.html#3141">3141</a>. <code>CopyConstructible</code> doesn't preserve source values</h3>
<p><b>Section:</b> 18.6 <a href="https://wg21.link/concepts.object">[concepts.object]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Casey Carter <b>Opened:</b> 2018-07-07 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>2
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>

<p>
The design intent of the <code>CopyConstructible</code> concept has always been that the source of the
constructions it requires be left unmodified. Before <a href="https://wg21.link/p0541r1">P0541R1</a>
reformulated the <code>Constructible</code> concept in terms of <code>is_constructible</code>, the wording
which is now in 18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>/5:
<blockquote>
This document uses a notational convention to specify which expressions declared in a
<i>requires-expression</i> modify which inputs: except where otherwise specified, [&hellip;] Operands that
are constant lvalues or rvalues are required to not be modified.
</blockquote>
indirectly enforced that requirement. Unfortunately, <em>nothing</em> in the current wording in
18.4.14 <a href="https://wg21.link/concept.copyconstructible">[concept.copyconstructible]</a> enforces that requirement.
</p>

<p><i>[2018-11 Reflector prioritization]</i></p>

<p>Set Priority to 2</p>

<strong>Previous resolution: [SUPERSEDED]</strong>

<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.</p>

<p>Change 18.4.14 <a href="https://wg21.link/concept.copyconstructible">[concept.copyconstructible]</a> as indicated:</p>
<blockquote>
<pre>
template&lt;class T&gt;
  concept CopyConstructible =
    MoveConstructible&lt;T&gt; &amp;&amp;
    Constructible&lt;T, T&amp;&gt; &amp;&amp; ConvertibleTo&lt;T&amp;, T&gt; &amp;&amp;
    Constructible&lt;T, const T&amp;&gt; &amp;&amp; ConvertibleTo&lt;const T&amp;, T&gt; &amp;&amp;
    Constructible&lt;T, const T&gt; &amp;&amp; ConvertibleTo&lt;const T, T&gt;;
</pre>
<p>
-1- If <code>T</code> is an object type, then let <code>v</code> be an lvalue of type (possibly <code>const</code>)
<code>T</code> or an rvalue of type <code>const T</code>. <code>CopyConstructible&lt;T&gt;</code> is satisfied
only if
</p><p>
(1.1) &mdash; After the definition <code>T u = v;</code>, <code>u</code> is equal to <code>v</code> <ins>and
<code>v</code> is unmodified</ins>.
</p><p>
(1.2) &mdash; <code>T(v)</code> is equal to <code>v</code> <ins>and does not modify <code>v</code></ins>.
</p>
</blockquote>
</blockquote>

<p><i>[2020-02-13 Per LWG review, Casey provides updated P/R wording.]</i></p>

<p><i>[2020-02 Status to Immediate on Thursday night in Prague.]</i></p>



<p id="res-3141"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4849">N4849</a>.</p>

<p>Change 18.4.14 <a href="https://wg21.link/concept.copyconstructible">[concept.copyconstructible]</a> as indicated:</p>
<blockquote>
<pre>
template&lt;class T&gt;
  concept copy_constructible =
    move_constructible&lt;T&gt; &amp;&amp;
    constructible_from&lt;T, T&amp;&gt; &amp;&amp; convertible_to&lt;T&amp;, T&gt; &amp;&amp;
    constructible_from&lt;T, const T&amp;&gt; &amp;&amp; convertible_to&lt;const T&amp;, T&gt; &amp;&amp;
    constructible_from&lt;T, const T&gt; &amp;&amp; convertible_to&lt;const T, T&gt;;
</pre>
<p>
-1- If <code>T</code> is an object type, then let <code>v</code> be an lvalue of type (possibly <code>const</code>)
<code>T</code> or an rvalue of type <code>const T</code>. <code>T</code> models <code>copy_constructible</code> only if
</p><p>
(1.1) &mdash; After the definition <code>T u = v;</code>, <code>u</code> is equal to <code>v</code> <ins>(18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>) and
<code>v</code> is not modified</ins>.
</p><p>
(1.2) &mdash; <code>T(v)</code> is equal to <code>v</code> <ins>and does not modify <code>v</code></ins>.
</p>
</blockquote>






</body>
</html>
