Documentation Home >> Headers >> <jss/experimental_future.hpp> Header >> std::experimental::packaged_task >> std::experimental::packaged_task Allocator Constructor

Construct a std::experimental::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 element args-i in args... shall be a value of the corresponding type ArgTypes-i in ArgTypes.... The return value shall be convertible to ResultType.

Effects:

Constructs a std::experimental::packaged_task instance with an associated asynchronous result of type ResultType that is not ready and an associated task of type Callable that is a copy of func. The memory for the asynchronous result and task is allocated through the allocator alloc.

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 <experimental/future>

See Also