<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3466: Specify the requirements for promise/future/shared_future consistently</title>
<meta property="og:title" content="Issue 3466: Specify the requirements for promise/future/shared_future consistently">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3466.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++23">C++23</a> status.</em></p>
<h3 id="3466"><a href="lwg-defects.html#3466">3466</a>. Specify the requirements for <code>promise</code>/<code>future</code>/<code>shared_future</code> consistently</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++23">C++23</a>
 <b>Submitter:</b> Tomasz Kami&nacute;ski <b>Opened:</b> 2020-07-18 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>3
</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++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The resolution of the LWG <a href="lwg-defects.html#3458" title="Is shared_future intended to work with arrays or function types? (Status: Resolved)">3458</a><sup><a href="https://cplusplus.github.io/LWG/issue3458" title="Latest snapshot">(i)</a></sup> clearly specified the requirement that
<code>future</code>/<code>shared_future</code> are ill-formed in situations when <code>T</code> is native array
or function type. This requirement was not strictly necessary for <code>future&lt;T&gt;</code> 
as it was already ill-formed due the signature of the <code>get</code> function (that would be 
ill-formed in such case), however it was still added for consistency of specification.
Similar, requirement should be introduced for the <code>promise&lt;T&gt;</code>, for which
any call to <code>get_future()</code> would be ill-formed, if <code>T</code> is of array or function type.
<p/>
[Note: <code>promise&lt;int[10]&gt;</code> is ill-formed for libstdc++ and libc++, see
<a href="https://godbolt.org/z/ffTW99">this code</a>]
</p>

<p><i>[2020-07-26; Reflector prioritization]</i></p>

<p>
Set priority to 3 after reflector discussions. Tim Song made the suggestion to replace the P/R wording
by the following alternative wording:
</p>
<blockquote><p>
<ins>For the primary template, <code>R</code> shall be an object type that meets the <i>Cpp17Destructible</i> requirements.</ins>
</p></blockquote>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/n4861">N4861</a>. 
</p>

<blockquote class="note">
<p>
Ideally the wording below would use a <i>Mandates:</i> element, but due to the still open
issue LWG <a href="lwg-active.html#3193" title="Mandates: and Expects: elements are not defined for types (Status: New)">3193</a><sup><a href="https://cplusplus.github.io/LWG/issue3193" title="Latest snapshot">(i)</a></sup> the wording below uses instead the more general "ill-formed"
vocabulary.
</p>
</blockquote>

<ol>
<li><p>Modify 32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a> as indicated:</p>

<blockquote>
<blockquote>
<pre>
namespace std {
  template&lt;class R&gt;
  class promise {
    [&hellip;]
  };
  [&hellip;]
}
</pre>
</blockquote>
<p>
<ins>-?- If <code>is_array_v&lt;R&gt;</code> is <code>true</code> or <code>is_function_v&lt;R&gt;</code> is <code>true</code>, 
the program is ill-formed.</ins>
</p>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2020-08-02; Daniel comments and provides alternative wording]</i></p>

<p>
Following the suggestion of Tim Song a revised wording is provided which is intended to replace the currently agreed on wording
for LWG <a href="lwg-defects.html#3458" title="Is shared_future intended to work with arrays or function types? (Status: Resolved)">3458</a><sup><a href="https://cplusplus.github.io/LWG/issue3458" title="Latest snapshot">(i)</a></sup>.
</p>

<p><i>[2020-08-21; Issue processing telecon: Tentatively Ready]</i></p>

<p>
Discussed a note clarifying that <em>Cpp17Destructible</em> disallows
arrays (as well as types without accessible destructors).
Can be added editorially.
</p>

<p><i>[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready &rarr; WP.]</i></p>



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

<ol>
<li><p>Modify 32.10.6 <a href="https://wg21.link/futures.promise">[futures.promise]</a> as indicated:</p>

<blockquote>
<blockquote>
<pre>
namespace std {
  template&lt;class R&gt;
  class promise {
    [&hellip;]
  };
  [&hellip;]
}
</pre>
</blockquote>
<p>
<ins>-?- For the primary template, <code>R</code> shall be an object type that meets the
<i>Cpp17Destructible</i> requirements.</ins>
<p/>
-1- The implementation provides the template <code>promise</code> and two specializations, <code>promise&lt;R&amp;&gt;</code> 
and <code>promise&lt;void&gt;</code>. These differ only in the argument type of the member functions 
<code>set_value</code> and <code>set_value_at_thread_exit</code>, as set out in their descriptions, below.
</p>
</blockquote>
</li>

<li><p>Modify 32.10.7 <a href="https://wg21.link/futures.unique.future">[futures.unique.future]</a> as indicated:</p>

<blockquote>
<blockquote>
<pre>
namespace std {
  template&lt;class R&gt;
  class future {
    [&hellip;]
  };
}
</pre>
</blockquote>
<p>
<ins>-?- For the primary template, <code>R</code> shall be an object type that meets the
<i>Cpp17Destructible</i> requirements.</ins>
<p/>
-4- The implementation provides the template <code>future</code> and two specializations, <code>future&lt;R&amp;&gt;</code> and 
<code>future&lt;void&gt;</code>. These differ only in the return type and return value of the member function <code>get</code>, 
as set out in its description, below.
</p>
</blockquote>
</li>

<li><p>Modify 32.10.8 <a href="https://wg21.link/futures.shared.future">[futures.shared.future]</a> as indicated:</p>

<blockquote>
<blockquote>
<pre>
namespace std {
  template&lt;class R&gt;
  class shared_future {
    [&hellip;]
  };
}
</pre>
</blockquote>
<p>
<ins>-?- For the primary template, <code>R</code> shall be an object type that meets the
<i>Cpp17Destructible</i> requirements.</ins>
<p/>
-4- The implementation provides the template <code>shared_future</code> and two specializations, 
<code>shared_future&lt;R&amp;&gt;</code> and <code>shared_future&lt;void&gt;</code>. These differ only in the return type 
and return value of the member function <code>get</code>, as set out in its description, below.
</p>
</blockquote>
</li>
</ol>





</body>
</html>
