<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4154: The Mandates for std::packaged_task's constructor from a callable entity should consider decaying</title>
<meta property="og:title" content="Issue 4154: The Mandates for std::packaged_task's constructor from a callable entity should consider decaying">
<meta property="og:description" content="C++ library issue. Status: WP">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4154.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#WP">WP</a> status.</em></p>
<h3 id="4154"><a href="lwg-defects.html#4154">4154</a>. The Mandates for <code>std::packaged_task</code>'s constructor from a callable entity should consider decaying</h3>
<p><b>Section:</b> 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a> <b>Status:</b> <a href="lwg-active.html#WP">WP</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2024-09-18 <b>Last modified:</b> 2024-11-28</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#futures.task.members">issues</a> in [futures.task.members].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#WP">WP</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Currently, 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a>/3 states:
<blockquote>
<i>Mandates</i>:
<code>is_invocable_r_v&lt;R, F&amp;, ArgTypes...&gt;</code> is <code class='backtick'>true</code>.
</blockquote>
where <code>F&amp;</code> can be a reference to a cv-qualified function object type.
</p>
<p>
However, in mainstream implementations (libc++, libstdc++, and MSVC STL),
the stored task object always has a cv-unqualified type,
and thus the cv-qualification is unrecognizable in <code class='backtick'>operator()</code>.
</p>
<p>
Since 22.10.17.3.2 <a href="https://wg21.link/func.wrap.func.con">[func.wrap.func.con]</a> uses a decayed type,
perhaps we should also so specify for <code class='backtick'>std::packaged_task</code>.
</p>

<p><i>[2024-10-02; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
</p>
<p>
"Fix preconditions, <code class='backtick'>f</code> doesn't need to be invocable, we only invoke the copy."
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">

<p>
This wording is relative to <a href="https://wg21.link/N4988" title=" Working Draft, Programming Languages — C++">N4988</a>.
</p>
<ol>
<li><p>Modify 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a> as indicated:</p>
<blockquote>
<p>
-3- <i>Mandates</i>:
<code>is_invocable_r_v&lt;R, <del>F</del><ins>decay_t&lt;F&gt;</ins>&amp;, ArgTypes...&gt;</code>
is <code class='backtick'>true</code>.
</p>
[...]
<p>
-5- <i>Effects</i>:
Constructs a new <code class='backtick'>packaged_task</code> object with a shared state and initializes
the object's stored task
<ins>of type <code>decay_t&lt;F&gt;</code></ins>
with <code>std::forward&lt;F&gt;(f)</code>.
</p>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2024-10-02; Jonathan provides improved wording]</i></p>

<p>Drop preconditions as suggested on reflector.</p>

<p><i>[2024-10-02; LWG telecon]</i></p>

<p>
Clarify that "of type <code>decay_t&lt;F&gt;</code>"
is supposed to be specifying the type of the stored task.
</p>

<p><i>[2024-10-09; LWG telecon: Move to Ready]</i></p>


<p><i>[Wrocław 2024-11-23; Status changed: Voting &rarr; WP.]</i></p>



<p id="res-4154"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4988" title=" Working Draft, Programming Languages — C++">N4988</a>.
</p>
<ol>
<li><p>Modify 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a> as indicated:</p>
<blockquote>
<pre><code>template&lt;class F&gt;
  explicit packaged_task(F&amp;&amp; f);</code></pre>
<p>
-2- <i>Constraints</i>:
<code>remove_cvref_t&lt;F&gt;</code> is not the same type as
<code>packaged_task&lt;R(ArgTypes...)&gt;</code>.
</p>
<p>
-3- <i>Mandates</i>:
<code>is_invocable_r_v&lt;R, <del>F</del><ins>decay_t&lt;F&gt;</ins>&amp;, ArgTypes...&gt;</code>
is <code class='backtick'>true</code>.
</p>
<p>
<del>-4- <i>Preconditions</i>:
Invoking a copy of <code class='backtick'>f</code> behaves the same as invoking <code class='backtick'>f</code>.
</del>
</p>
<p>
-5- <i>Effects</i>:
Constructs a new <code class='backtick'>packaged_task</code> object with
<ins>a stored task of type <code>decay_t&lt;F&gt;</code> and</ins>
a shared state
<ins>. Initializes</ins>
<del>and initializes</del>
the object's stored task
with <code>std::forward&lt;F&gt;(f)</code>.
</p>
</blockquote>
</li>
</ol>





</body>
</html>
