deduction guides for std::packaged_task

From cppreference.com
 
 
Concurrency support library
Threads
(C++11)
(C++20)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
Free functions for atomic operations
Free functions for atomic flags
Memory ordering
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
 
 
Defined in header <future>
template<class R, class... Args>
packaged_task(R(*)(Args...)) -> packaged_task<R(Args...)>;
(1) (since C++17)
template<class F>
packaged_task(F) -> packaged_task</*see below*/>;
(2) (since C++17)
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) for some class type G. The deduced type is std::packaged_task<R(A...)>.

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; }; // deduces packaged_task<int(double)>
}