Title
Missing packaged_task deduction guides
Status
new
Section
[futures.task]
Submitter
Marc Mutz

Created on 2018-06-08.00:00:00, last changed 2018-06-25.00:47:25.

Messages

Date: 2018-06-25.00:47:25

Proposed resolution:

This wording is relative to N4750.

  1. Modify [futures.task], class template packaged_task synopsis, as indicated:

    namespace std {
      […]
      template<class R, class... ArgTypes>
      class packaged_task<R(ArgTypes...)> {
        […]
      };
      
      template<class R, class... ArgTypes>
      packaged_task(R (*)( ArgTypes ...)) -> packaged_task<R( ArgTypes...)>;
    
      template<class F> packaged_task(F) -> packaged_task<see below>;
      
      template<class R, class... ArgTypes>
        void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
    }
    
  2. Modify [futures.task.members] as indicated:

    template<class F>
      packaged_task(F&& f);
    
    […]
    template<class F> packaged_task(F) -> packaged_task<see below>;
    

    -?- Remarks: This deduction guide participates in overload resolution only if &F::operator() is well-formed when treated as an unevaluated operand. In that case, if decltype(&F::operator()) is of the form R(G::*)(A...) cv &opt noexceptopt for a class type G, then the deduced type is packaged_task<R(A...)>.

    […]
    packaged_task(packaged_task&& rhs) noexcept;
    
Date: 2018-06-23.00:00:00

[ 2018-06-23 after reflector discussion ]

Priority set to 3

Date: 2018-06-08.00:00:00

std::function has deduction guides, but std::packaged_task, 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.

History
Date User Action Args
2018-06-25 00:47:25adminsetmessages: + msg9947
2018-06-16 15:02:29adminsetmessages: + msg9880
2018-06-08 00:00:00admincreate