<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1283: MoveConstructible and MoveAssignable need clarification
of moved-from state</title>
<meta property="og:title" content="Issue 1283: MoveConstructible and MoveAssignable need clarification
of moved-from state">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1283.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#Resolved">Resolved</a> status.</em></p>
<h3 id="1283"><a href="lwg-defects.html#1283">1283</a>. <code>MoveConstructible</code> and <code>MoveAssignable</code> need clarification
of moved-from state</h3>
<p><b>Section:</b> 16.4.4.2 <a href="https://wg21.link/utility.arg.requirements">[utility.arg.requirements]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Howard Hinnant <b>Opened:</b> 2009-12-12 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#utility.arg.requirements">active issues</a> in [utility.arg.requirements].</p>
<p><b>View all other</b> <a href="lwg-index.html#utility.arg.requirements">issues</a> in [utility.arg.requirements].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses UK 150</b></p>

<p>
There is on going confusion over what one can and can not do with a moved-from
object (e.g.
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3009.html#UK150">UK 150</a>,
<a href="lwg-closed.html#910" title="Effects of MoveAssignable (Status: NAD Concepts)">910</a><sup><a href="https://cplusplus.github.io/LWG/issue910" title="Latest snapshot">(i)</a></sup>).
This issue attempts to clarify that moved-from objects are valid objects with an
unknown state.
</p>

<p><i>[
2010-01-22 Wording tweaked by Beman.
]</i></p>


<p><i>[
2010-01-22 Moved to Tentatively Ready after 5 positive votes on c++std-lib.
]</i></p>


<p><i>[
2010-01-23 Alisdair opens:
]</i></p>


<blockquote>
<p>
I'm afraid I must register an objection.
</p>

<p>
My primary objection is that I have always been opposed to this kind of a
resolution as over-constraining.  My preferred example is a call implementing
the pImpl idiom via <code>unique_ptr</code>.  Once the pImpl has been moved from, it
is no longer safe to call the vast majority of the object's methods, yet I see
no reason to make such a type unusable in the standard library.  I would prefer
a resolution along the lines suggested in the UK comment, which only requires
that the object can be safely destroyed, and serve as the target of an
assignment operator (if supported.)
</p>

<p>
However, I will not hold the issue up if I am a lone dissenting voice on this
(yes, that is a call to hear more support, or I will drop that objection in
Pittsburgh)
</p>

<p>
With the proposed wording, I'm not clear what the term 'valid object' means.  In
my example above, is a pImpl holding a null pointer 'valid'?  What about a float
holding a signalling NaN?  What determines if an object is valid?  Without a
definition of a valid/invalid object, I don't think this wording adds anything,
and this is an objection that I do want resolved.
</p>

<p><i>[
2010-01-24 Alisdair removes his objection.
]</i></p>


<p><i>[
2010-01-24 Moved to Tentatively Ready after 5 positive votes on c++std-lib.
]</i></p>


</blockquote>

<p><i>[
2010-02-10 Reopened.  The wording here has been merged into <a href="lwg-defects.html#1309" title="Missing expressions for Move/CopyConstructible (Status: C++11)">1309</a><sup><a href="https://cplusplus.github.io/LWG/issue1309" title="Latest snapshot">(i)</a></sup>.
]</i></p>


<p><i>[
2010-02-10 Moved to Tentatively <del>NAD Editorial</del><ins>Resolved</ins> after 5 postive votes on
c++std-lib.  Rationale added below.
]</i></p>




<p><b>Rationale:</b></p>
<p>
This issue is now addressed by <a href="lwg-defects.html#1309" title="Missing expressions for Move/CopyConstructible (Status: C++11)">1309</a><sup><a href="https://cplusplus.github.io/LWG/issue1309" title="Latest snapshot">(i)</a></sup>.
</p>


<p id="res-1283"><b>Proposed resolution:</b></p>
<p>
Change the follwing tables in 16.4.4.2 <a href="https://wg21.link/utility.arg.requirements">[utility.arg.requirements]</a> as shown:
</p>

<blockquote>

<table border="1">
<caption>Table 33 &mdash; <code>MoveConstructible</code> requirements <b>[moveconstructible]</b></caption>
<tr>
<th>Expression</th>
<th>Post-condition</th>
</tr>
<tr>
<td>
<code>T t(rv)</code>
</td>
<td>
<code>t</code> is equivalent to the value of <code>rv</code> before the construction.
</td>
</tr>
<tr>
<td colspan="2">
[<i>Note:</i>
<del>There is no requirement on the value of <code>rv</code> after the
construction.</del>
<ins><code>rv</code> remains a valid object.  Its state is unspecified.</ins>
&mdash; <i>end note</i>]
</td>
</tr>
</table>

</blockquote>
<blockquote>

<table border="1">
<caption>Table 35 &mdash; <code>MoveAssignable</code> requirements <b>[moveassignable]</b></caption>
<tr>
<th>Expression</th>
<th>Return type</th>
<th>Return value</th>
<th>Post-condition</th>
</tr>
<tr>
<td>
<code>t = rv</code>
</td>
<td>
<code>T&amp;</code>
</td>
<td>
<code>t</code>
</td>
<td>
<code>t</code> is equivalent to the value of <code>rv</code> before the assigment.
</td>
</tr>
<tr>
<td colspan="4">
[<i>Note:</i>
<del>There is no requirement on the value of <code>rv</code> after the
assignment.</del>
<ins><code>rv</code> remains a valid object.  Its state is unspecified.</ins>
&mdash; <i>end note</i>]
</td>
</tr>
</table>

</blockquote>





</body>
</html>
