Construct a std::packaged_task object with an
associated task and asynchronous result, using the supplied allocator
to allocate memory for the associated asynchronous result and task.
template<typename Allocator,typename Callable> packaged_task(std::allocator_arg_t, Allocator const& alloc,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. The memory for the asynchronous result and task is allocated through the allocatoralloc.- Throws:
Any exception thrown by the allocator when trying to allocate memory for the asynchronous result or task. Any exception thrown by the copy or move constructor of
Callable.
Header
#include <future>