2976. Dangling uses_allocator specialization for packaged_task

Section: 33.6.10 [futures.task], 33.6.2 [future.syn], 33.6.10.2 [futures.task.nonmembers] Status: WP Submitter: Tim Song Opened: 2017-06-13 Last modified: 2017-11-13

Priority: 3

View all other issues in [futures.task].

View all issues with WP status.

Discussion:

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.6.2 [future.syn], header <future> synopsis, and 33.6.10 [futures.task], class template packaged_task synopsis, as indicated:

    template <class R, class Alloc>
    struct uses_allocator<packaged_task<R>, Alloc>;
    
  2. Modify 33.6.10.2 [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 (20.5.3.5).

  3. Modify 33.6.10.1 [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.