Documentation Home >> Headers >> <jss/experimental_future.hpp> Header >> std::experimental::packaged_task >> std::experimental::packaged_task Construction from a function

Construct a std::experimental::packaged_task object with an associated task and asynchronous result.

template<
    typename FunctionResultType,
    typename FunctionArgs...>
packaged_task(
    FunctionResultType (*func)(FunctionArgs...));

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 that is a copy of func.

Throws:

An exception of type std::bad_alloc if the constructor is unable to allocate memory for the asynchronous result.

Header

#include <experimental/future>

See Also