Title
Missing packaged_task deduction guides
Status
c++23
Section
[futures.task]
Submitter
Marc Mutz

Created on 2018-06-08.00:00:00 last changed 11 months ago

Messages

Date: 2020-11-09.20:31:48

Proposed resolution:

This wording is relative to N4849.

  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>;
    

    -?- Constraints: &F::operator() is well-formed when treated as an unevaluated operand and decltype(&F::operator()) is of the form R(G::*)(A...) cv &opt noexceptopt for a class type G.

    -?- Remarks: The deduced type is packaged_task<R(A...)>.

    […]
    packaged_task(packaged_task&& rhs) noexcept;
    
Date: 2020-11-09.00:00:00

[ 2020-11-09 Approved In November virtual meeting. Status changed: Ready → WP. ]

Date: 2020-02-14.15:01:42

[ Status to Ready on Friday in Prague. ]

Date: 2020-02-15.00:00:00

[ 2020-02-14; Prague ]

Do we want a feature test macro for this new feature?

F N A
1 7 6
Date: 2020-02-15.00:00:00

[ 2020-02-13; Prague ]

LWG improves wording matching Marshall's Mandating paper.

Date: 2018-06-23.00:00:00

[ 2018-06-23 after reflector discussion ]

Priority set to 3

Previous resolution [SUPERSEDED]:

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-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
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2020-11-09 20:31:48adminsetmessages: + msg11540
2020-11-09 20:31:48adminsetstatus: ready -> wp
2020-02-14 15:01:42adminsetstatus: new -> ready
2020-02-14 15:01:42adminsetmessages: + msg11124
2020-02-14 15:01:42adminsetstatus: new -> new
2020-02-14 13:26:26adminsetmessages: + msg11122
2020-02-14 08:01:28adminsetstatus: ready -> new
2020-02-13 21:47:47adminsetmessages: + msg11087
2018-06-25 00:47:25adminsetmessages: + msg9983
2018-06-16 15:02:29adminsetmessages: + msg9916
2018-06-08 00:00:00admincreate