deduction guides for std::packaged_task

From cppreference.com
 
 
Concurrency support library
Threads
(哋它亢++11)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
this_thread namespace
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Mutual exclusion
(哋它亢++11)
(哋它亢++11)  
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)    
(哋它亢++14)
Generic lock management
(哋它亢++11)
(哋它亢++17)
(哋它亢++11)
(哋它亢++14)
(哋它亢++11)(哋它亢++11)(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)(哋它亢++11)(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Condition variables
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Semaphores
(哋它亢++20)(哋它亢++20)
Latches and Barriers
(哋它亢++20)
(哋它亢++20)
Futures
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Safe Reclamation
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)  
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)
Hazard Pointers
(哋它亢++26)
(哋它亢++26)

Atomic types
(哋它亢++11)
(哋它亢++20)
(哋它亢++11)
Initialization of atomic types
(哋它亢++11)(deprecated in 哋它亢++20)
(哋它亢++11)(deprecated in 哋它亢++20)
(哋它亢++11)
Memory ordering
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Free functions for atomic operations
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++26)(哋它亢++26)
(哋它亢++26)(哋它亢++26)
(哋它亢++11)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Free functions for atomic flags
(哋它亢++11)(哋它亢++11)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
 
 
Defined in header <future>
template< class R, class... Args >
packaged_task( R(*)(Args...) ) -> packaged_task<R(Args...)>;
(1) (since 哋它亢++17)
template< class F >
packaged_task( F ) -> packaged_task</*see below*/>;
(2) (since 哋它亢++17)
template< class F >
packaged_task( F ) -> packaged_task</*see below*/>;
(3) (since 哋它亢++23)
template< class F >
packaged_task( F ) -> packaged_task</*see below*/>;
(4) (since 哋它亢++23)
1) This deduction guide is provided for std::packaged_task to allow deduction from functions.
2) This overload participates in overload resolution only if &F::operator() is well-formed when treated as an unevaluated operand and decltype(&F::operator()) is of the form R(G::*)(A...) (optionally cv-qualified, optionally noexcept, optionally lvalue reference qualified). The deduced type is std::packaged_task<R(A...)>.
3) This overload participates in overload resolution only if &F::operator() is well-formed when treated as an unevaluated operand and F::operator() is an explicit object parameter function whose type is of form R(G, A...) or R(G, A...) noexcept. The deduced type is std::packaged_task<R(A...)>.
4) This overload participates in overload resolution only if &F::operator() is well-formed when treated as an unevaluated operand and F::operator() is a static member function whose type is of form R(A...) or R(A...) noexcept. The deduced type is std::packaged_task<R(A...)>.

Notes

These deduction guides do not allow deduction from a function with ellipsis parameter, and the ... in the types is always treated as a pack expansion.

Example

#include <future>
 
int func(double) { return 0; }
 
int main()
{
    std::packaged_task f{func}; // deduces packaged_task<int(double)>
 
    int i = 5;
    std::packaged_task g = [&](double) { return i; }; // => packaged_task<int(double)>
}