2976. Dangling uses_allocator specialization for packaged_task

Section: 33.10.10 [futures.task], 33.10.2 [future.syn], [futures.task.nonmembers] Status: C++20 Submitter: Tim Song Opened: 2017-06-13 Last modified: 2021-02-25 10:48:01 UTC

Priority: 3

View all other issues in [futures.task].

View all issues with C++20 status.


When LWG 2921 removed allocator support from packaged_task, it forgot to remove the uses_allocator partial specialization.

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

[2017-06-26, Billy O'Neal reopens]

I think 2921 was resolved in error. If promise<T> can have an allocator, there's no reason for packaged_task<T> to not have one. If we remove it from packaged_task we should remove it from promise as well.

Note that I am not objecting to removing allocator support here, I'm objecting to the "remove it because this looks like std::function" case. packaged_task has none of the std::function problems because the function inside a given packaged_task is not reassignable.

If LWG decides to remove allocator support here then there are more bits that need to be struck, e.g. [futures.task.members] (5.3).

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

The additional point in the P/R effectively reverts the second part of the resolution of 2752.

The alternative resolution for this issue is, of course, to just revert the resolution of 2921. In that case 2245 needs to be reopened.

[2016-07, Toronto Saturday afternoon issues processing]

Status to Ready

Proposed resolution:

This wording is relative to N4659.

  1. Modify 33.10.2 [future.syn], header <future> synopsis, and 33.10.10 [futures.task], class template packaged_task synopsis, as indicated:

    template <class R, class Alloc>
    struct uses_allocator<packaged_task<R>, Alloc>;
  2. Modify [futures.task.nonmembers] as indicated:

    template <class R, class Alloc>
      struct uses_allocator<packaged_task<R>, Alloc>
        : true_type { };

    -2- Requires: Alloc shall be an Allocator (

  3. Modify [futures.task.members]/5 as indicated:

    template <class F>
      packaged_task(F&& F);

    -2- Requires: […]

    -3- Remarks: […]

    -4- Effects: […]

    -5- Throws:

    — Aany exceptions thrown by the copy or move constructor of f., or

    — For the first version, bad_alloc if memory for the internal data structures could not be allocated.

    — For the second version, any exceptions thrown by allocator_traits<Allocator>::template rebind_traits<unspecified>::allocate.