std::packaged_task
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Getting the result | ||||
| Execution | ||||
| Non-member functions | ||||
| Helper classes | ||||
(until C++17) | ||||
| Deduction guides(C++17) |
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) |
template<class F> packaged_task( F)-> packaged_task</*see below*/>; | (3) | (since C++23) |
template<class F> packaged_task( F)-> packaged_task</*see below*/>; | (4) | (since C++23) |
These deduction guides do not allow deduction from a function withellipsis parameter, and the... in the types is always treated as apack expansion.
#include <future> int func(double){return0;} 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)>}