<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2096: Incorrect constraints of future::get in regard to MoveAssignable</title>
<meta property="og:title" content="Issue 2096: Incorrect constraints of future::get in regard to MoveAssignable">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2096.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++14">C++14</a> status.</em></p>
<h3 id="2096"><a href="lwg-defects.html#2096">2096</a>. Incorrect constraints of <code>future::get</code> in regard to <code>MoveAssignable</code></h3>
<p><b>Section:</b> 32.10.7 <a href="https://wg21.link/futures.unique.future">[futures.unique.future]</a> <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2011-11-02 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#futures.unique.future">issues</a> in [futures.unique.future].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++14">C++14</a> status.</p>
<p><b>Discussion:</b></p>

<p>
 [futures.unique_future] paragraph 15 says the following:
</p>
<blockquote><pre>
R future::get();
</pre></blockquote>
<p>
&hellip;
<p/>
-15- <i>Returns</i>:
</p>
<ul>
<li>
<p><code>future::get()</code> returns the value stored in the object’s shared state. If the type of the value is
<code>MoveAssignable</code> the returned value is moved, otherwise it is copied.
<p/>
&hellip;
</p>
</li>
</ul>
<p>
There are some problems with the description:
<p/>
"If the type of the value is <code>MoveAssignable</code> the returned value is moved, otherwise it is copied."
</p>
<ol>
<li>It seems to impose unrealistic constraints on implementations, because how could an implementor
recognize whether a user-defined type satisfies the semantics of <code>MoveAssignable</code>? This should be
based solely on a pure expression-based requirement, if this is an requirement for implementations.
</li>
<li>
Reducing <code>MoveAssignable</code> to the plain expression part <code>std::is_move_assignable</code>
would solvs (1), but raises another question, namely why a <em>move-assignment</em> should be relevant
for a function return based on the value stored in the future state? We would better fall back to
<code>std::is_move_constructible</code> instead.
</li>
<li><p>The last criticism I have is about the part
<p/>
"the returned value is moved, otherwise it is copied"
<p/>
because an implementation won't be able to recognize what the user-defined type
will do during an expression that is prepared by the implementation. I think the
wording is intended to <em>allow</em> a move by seeding with an rvalue expression via
<code>std::move</code> (or equivalent), else the result will be an effective
copy construction.
</p>
</li>
</ol>

<p><i>[2011-11-28 Moved to Tentatively Ready after 5 positive votes on c++std-lib.]</i></p>




<p id="res-2096"><b>Proposed resolution:</b></p>
<p>This wording is relative to the FDIS.</p>

<p>Change  [futures.unique_future] paragraph 15 as indicated:</p>

<blockquote><pre>
R future::get();
</pre></blockquote>
<p>
&hellip;
<p/>
-15- <i>Returns</i>:
</p>
<ul>
<li>
<p><code>future::get()</code> returns the value <ins><code>v</code></ins> stored in the object’s shared
state <ins>as <code>std::move(v)</code></ins>. <del>If the type of the value is <code>MoveAssignable</code>
the returned value is moved, otherwise it is copied.</del>
<p/>
&hellip;
</p>
</li>
</ul>






</body>
</html>
