<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2976: Dangling uses_allocator specialization for packaged_task</title>
<meta property="og:title" content="Issue 2976: Dangling uses_allocator specialization for packaged_task">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2976.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++20">C++20</a> status.</em></p>
<h3 id="2976"><a href="lwg-defects.html#2976">2976</a>. Dangling <code>uses_allocator</code> specialization for <code>packaged_task</code></h3>
<p><b>Section:</b> 32.10.10 <a href="https://wg21.link/futures.task">[futures.task]</a>, 32.10.2 <a href="https://wg21.link/future.syn">[future.syn]</a>, 32.10.10.3 <a href="https://wg21.link/futures.task.nonmembers">[futures.task.nonmembers]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2017-06-13 <b>Last modified:</b> 2021-02-25</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++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
When LWG <a href="lwg-defects.html#2921" title="packaged_task and type-erased allocators (Status: C++17)">2921</a><sup><a href="https://cplusplus.github.io/LWG/issue2921" title="Latest snapshot">(i)</a></sup> removed allocator support from <code>packaged_task</code>, it forgot
to remove the <code>uses_allocator</code> partial specialization.
</p>

<p><i>[
2017-06-26 Moved to Tentatively Ready after 6 positive votes on c++std-lib.
]</i></p>


<p><i>[2017-06-26, Billy O'Neal reopens]</i></p>

<p>
I think <a href="lwg-defects.html#2921" title="packaged_task and type-erased allocators (Status: C++17)">2921</a><sup><a href="https://cplusplus.github.io/LWG/issue2921" title="Latest snapshot">(i)</a></sup> was resolved in error. If <code>promise&lt;T&gt;</code> can have an allocator, there's no 
reason for <code>packaged_task&lt;T&gt;</code> to not have one. If we remove it from <code>packaged_task</code> we should 
remove it from <code>promise</code> as well.
<p/>
Note that I am not objecting to removing allocator support here, I'm objecting to the "remove it because this looks 
like <code>std::function</code>" case. <code>packaged_task</code> has none of the <code>std::function</code> problems because 
the function inside a given <code>packaged_task</code> is not reassignable.
<p/>
If LWG decides to remove allocator support here then there are more bits that need to be struck, e.g. 
<a href="http://eel.is/c++draft/futures#task.members-5.3">[futures.task.members] (5.3)</a>.
</p>

<p><i>[2017-06-26, Tim updates P/R to remove more dangling bits.]</i></p>

<p>
The additional point in the P/R effectively reverts the second part of the resolution of <a href="lwg-defects.html#2752" title="&quot;Throws:&quot; clauses of async and packaged_task are unimplementable (Status: C++17)">2752</a><sup><a href="https://cplusplus.github.io/LWG/issue2752" title="Latest snapshot">(i)</a></sup>.
<p/>
The alternative resolution for this issue is, of course, to just revert the resolution of 2921. In that case <a href="lwg-defects.html#2245" title="packaged_task::reset() memory allocation (Status: Resolved)">2245</a><sup><a href="https://cplusplus.github.io/LWG/issue2245" title="Latest snapshot">(i)</a></sup> needs to be reopened.
</p>

<p><i>[2016-07, Toronto Saturday afternoon issues processing]</i></p>

<p>Status to Ready</p>


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

<ol>
<li>
<p>Modify 32.10.2 <a href="https://wg21.link/future.syn">[future.syn]</a>, header <code>&lt;future&gt;</code> synopsis, and
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>
<del>template &lt;class R, class Alloc&gt;
struct uses_allocator&lt;packaged_task&lt;R&gt;, Alloc&gt;;</del>
</pre>
</blockquote>
</li>

<li>
<p>Modify 32.10.10.3 <a href="https://wg21.link/futures.task.nonmembers">[futures.task.nonmembers]</a> as indicated:</p>

<blockquote>
<pre>
<del>template &lt;class R, class Alloc&gt;
  struct uses_allocator&lt;packaged_task&lt;R&gt;, Alloc&gt;
    : true_type { };</del>
</pre>
<blockquote>
<p>
<del>-2- <i>Requires:</i> <code>Alloc</code> shall be an Allocator (20.5.3.5).</del>
</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.10.10.2 <a href="https://wg21.link/futures.task.members">[futures.task.members]</a>/5 as indicated:</p>

<blockquote>
<pre>
template &lt;class F&gt;
  packaged_task(F&amp;&amp; F);
</pre>
<blockquote>
<p>
-2- <i>Requires:</i> [&hellip;]
</p>
<p>
-3- <i>Remarks:</i> [&hellip;]
</p>
<p>
-4- <i>Effects:</i> [&hellip;]
</p>
<p>
-5- <i>Throws:</i>
<blockquote>
<p> <del> &mdash; A</del><ins>a</ins>ny exceptions thrown by the copy or move constructor of <code>f</code><del>.</del><ins>, or</ins> </p>
<p> <del>&mdash; For the first version,</del> <code>bad_alloc</code> if memory for the internal data structures could not be allocated.</p>
<p> <del>&mdash; For the second version, any exceptions thrown by <code>allocator_traits&lt;Allocator&gt;::template rebind_traits&lt;<i>unspecified</i>&gt;::allocate</code>.</del></p>
</blockquote>
</p>
</blockquote>
</blockquote>
</li>

</ol>






</body>
</html>
