<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3117: Missing packaged_task deduction guides</title>
<meta property="og:title" content="Issue 3117: Missing packaged_task deduction guides">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3117.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="3117"><a href="lwg-defects.html#3117">3117</a>. Missing <code>packaged_task</code> deduction guides</h3>
<p><b>Section:</b> 32.10.10 <a href="https://wg21.link/futures.task">[futures.task]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Marc Mutz <b>Opened:</b> 2018-06-08 <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.task">issues</a> in [futures.task].</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>
<code>std::function</code> has deduction guides, but <code>std::packaged_task</code>, which is otherwise very
similar, does not. This is surprising to users and I can think of no reason for the former
to be treated differently from the latter. I therefore propose to add deduction guides for
packaged task with the same semantics as the existing ones for function.
</p>

<p><i>[2018-06-23 after reflector discussion]</i></p>

<p>Priority set to 3</p>

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

<ol>
<li><p>Modify 32.10.10 <a href="https://wg21.link/futures.task">[futures.task]</a>, class template <code>packaged_task</code> synopsis, as indicated:</p>
<blockquote>
<pre>
namespace std {
  [&hellip;]
  template&lt;class R, class... ArgTypes&gt;
  class packaged_task&lt;R(ArgTypes...)&gt; {
    [&hellip;]
  };
  
  <ins>template&lt;class R, class... ArgTypes&gt;
  packaged_task(R (*)( ArgTypes ...)) -&gt; packaged_task&lt;R( ArgTypes...)&gt;;

  template&lt;class F&gt; packaged_task(F) -&gt; packaged_task&lt;<i>see below</i>&gt;;</ins>
  
  template&lt;class R, class... ArgTypes&gt;
    void swap(packaged_task&lt;R(ArgTypes...)&gt;&amp; x, packaged_task&lt;R(ArgTypes...)&gt;&amp; y) noexcept;
}
</pre>
</blockquote>
</li>

<li><p>Modify 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a> as indicated:</p>
<blockquote>
<pre>
template&lt;class F&gt;
  packaged_task(F&amp;&amp; f);
</pre>
[&hellip;]
<pre>
<ins>template&lt;class F&gt; packaged_task(F) -&gt; packaged_task&lt;<i>see below</i>&gt;;</ins>
</pre>
<blockquote>
<p>
<ins>-?- <i>Remarks:</i> This deduction guide participates in overload resolution only if <code>&amp;F::operator()</code> 
is well-formed when treated as an unevaluated operand. In that case, if <code>decltype(&amp;F::operator())</code> is of the 
form <code>R(G::*)(A...) <i>cv</i> &amp;<sub><i>opt</i></sub> noexcept<sub><i>opt</i></sub></code> for a class type <code>G</code>, 
then the deduced type is <code>packaged_task&lt;R(A...)&gt;</code>.</ins>
</p>
</blockquote>
[&hellip;]
<pre>
packaged_task(packaged_task&amp;&amp; rhs) noexcept;
</pre>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2020-02-13; Prague]</i></p>

<p>
LWG improves wording matching Marshall's Mandating paper.
</p>

<p><i>[2020-02-14; Prague]</i></p>

<p>
Do we want a feature test macro for this new feature?
</p>
<blockquote><pre>
F N A
1 7 6
</pre></blockquote>

<p><i>[Status to Ready on Friday in Prague.]</i></p>

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



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

<ol>
<li><p>Modify 32.10.10 <a href="https://wg21.link/futures.task">[futures.task]</a>, class template <code>packaged_task</code> synopsis, as indicated:</p>
<blockquote>
<pre>
namespace std {
  [&hellip;]
  template&lt;class R, class... ArgTypes&gt;
  class packaged_task&lt;R(ArgTypes...)&gt; {
    [&hellip;]
  };
  
  <ins>template&lt;class R, class... ArgTypes&gt;
  packaged_task(R (*)(ArgTypes...)) -&gt; packaged_task&lt;R(ArgTypes...)&gt;;

  template&lt;class F&gt; packaged_task(F) -&gt; packaged_task&lt;<i>see below</i>&gt;;</ins>
  
  template&lt;class R, class... ArgTypes&gt;
    void swap(packaged_task&lt;R(ArgTypes...)&gt;&amp; x, packaged_task&lt;R(ArgTypes...)&gt;&amp; y) noexcept;
}
</pre>
</blockquote>
</li>

<li><p>Modify 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a> as indicated:</p>
<blockquote>
<pre>
template&lt;class F&gt;
  packaged_task(F&amp;&amp; f);
</pre>
[&hellip;]
<pre>
<ins>template&lt;class F&gt; packaged_task(F) -&gt; packaged_task&lt;<i>see below</i>&gt;;</ins>
</pre>
<blockquote>
<p>
<ins>-?- <i>Constraints:</i> <code>&amp;F::operator()</code> is well-formed when treated as an unevaluated operand 
and <code>decltype(&amp;F::operator())</code> is of the form <code>R(G::*)(A...) <i>cv</i> &amp;<sub><i>opt</i></sub> 
noexcept<sub><i>opt</i></sub></code> for a class type <code>G</code>.</ins>
<p/>
<ins>-?- <i>Remarks:</i> The deduced type is <code>packaged_task&lt;R(A...)&gt;</code>.</ins>
</p>
</blockquote>
[&hellip;]
<pre>
packaged_task(packaged_task&amp;&amp; rhs) noexcept;
</pre>
</blockquote>
</li>
</ol>





</body>
</html>
