<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2098: Minor Inconsistency between promise::set_value and promise::set_value_at_thread_exit</title>
<meta property="og:title" content="Issue 2098: Minor Inconsistency between promise::set_value and promise::set_value_at_thread_exit">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2098.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="2098"><a href="lwg-defects.html#2098">2098</a>. Minor Inconsistency between <code>promise::set_value</code> and <code>promise::set_value_at_thread_exit</code></h3>
<p><b>Section:</b> 32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a> <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Pete Becker <b>Opened:</b> 2011-11-14 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#futures.promise">issues</a> in [futures.promise].</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>
32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a>&#47;16 says that <code>promise::set_value(const R&amp;)</code> throws any exceptions 
thrown by <code>R</code>'s copy constructor, and that <code>promise_set_value(R&amp;&amp;)</code> throws any exceptions 
thrown by <code>R</code>'s move constructor.
<p/>
32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a>&#47;22 is the Throws: clause for <code>promise::set_value_at_thread_exit</code>. It 
has no corresponding requirements, only that these functions throw "<code>future_error</code> if an error condition 
occurs."
<p/>
Daniel suggests wording to fix this: The approach is a bit more ambitious and also attempts to fix wording glitches
of 32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a>&#47;16, because it would be beyond acceptable efforts of implementations to 
determine whether a constructor call of a user-defined type will indeed call a copy constructor or move constructor 
(in the first case it might be a template constructor, in the second case it might also be a copy-constructor, 
if the type has no move constructor).
</p>

<p><i>[2012, Portland: move to Review]</i></p>

<p>
Moved to Review by the concurrency working group, with no further comments.
</p>

<p><i>[2013-04-20, Bristol]</i></p>

<p>Accepted for the working paper</p>



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

<ol>
<li><p>Change 32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a>&#47;16 as indicated:</p>
<blockquote><pre>
void promise::set_value(const R&amp; r);
void promise::set_value(R&amp;&amp; r);
void promise&lt;R&amp;&gt;::set_value(R&amp; r);
void promise&lt;void&gt;::set_value();
</pre><blockquote><p>
[&hellip;]
<p/>
-16- <i>Throws</i>:
</p>
<ul>
<li><code>future_error</code> if its shared state already has a stored value or exception, or</li>
<li>for the first version, any exception thrown by the <del>copy constructor 
of</del><ins>constructor selected to copy an object of</ins> <code>R</code>, or</li>
<li>for the second version, any exception thrown by the <del>move constructor 
of</del><ins>constructor selected to move an object of</ins> <code>R</code>.</li>
</ul>
</blockquote></blockquote>
</li>

<li><p>Change 32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a>&#47;22 as indicated:</p>
<blockquote><pre>
void promise::set_value_at_thread_exit(const R&amp; r);
void promise::set_value_at_thread_exit(R&amp;&amp; r);
void promise&lt;R&amp;&gt;::set_value_at_thread_exit(R&amp; r);
void promise&lt;void&gt;::set_value_at_thread_exit();
</pre><blockquote><p>
[&hellip;]
<p/>
-16- <i>Throws</i>: <del><code>future_error</code> if an error condition occurs.</del>
</p>
<ul>
<li><ins><code>future_error</code> if its shared state already has a stored value or exception, or</ins></li>
<li><ins>for the first version, any exception thrown by the constructor selected to copy an object of <code>R</code>, or</ins></li>
<li><ins>for the second version, any exception thrown by the constructor selected to move an object of <code>R</code>.</ins></li>
</ul>
</blockquote></blockquote>
</li>
</ol>






</body>
</html>
