Construct a std::packaged_task object with an
associated task and asynchronous result.
template<typename Callable> packaged_task(Callable func);
- Preconditions:
The expression
func(args...)shall be valid, where each elementargs-i inargs...shall be a value of the corresponding typeArgTypes-i inArgTypes.... The return value shall be convertible toResultType.- Effects:
Constructs a
std::packaged_taskinstance with an associated asynchronous result of typeResultTypethat is not ready and an associated task of typeCallablethat is a copy offunc.- Throws:
An exception of type
std::bad_allocif the constructor is unable to allocate memory for the asynchronous result. Any exception thrown by the copy or move constructor ofCallable.
Header
#include <future>