Invoke the task associated with a std::packaged_task instance, and
store the return value or exception in the associated asynchronous result.
void operator()(ArgTypes... args);
- Preconditions:
*thishas an associated task.- Effects:
Invoke the associated task
funcas-ifINVOKE(func,args...). If the invocation returns normally, store the return value in the asynchronous result associated with*this. If the invocation returns with an exception, store the exception in the asynchronous result associated with*this.- Postconditions:
The asynchronous result associated with
*thisis ready with a stored value or exception. Any threads blocked waiting for the asynchronous result are unblocked.- Throws:
An exception of type
std::future_errorwith an error code ofstd::future_errc::promise_already_satisfiedif the asynchronous result is already ready..- Synchronization:
A successful call to the function call operator happens-before a call to
std::future<ResultType>::get()orstd::shared_future<ResultType>::get()which retrieves the value or exception stored.
Header
#include <future>