When the
packaged_task object is invoked, its stored task is invoked and the
result (whether normal or exceptional) stored in the shared state
. Any futures that
share the shared state will then be able to access the stored result
.namespace std {
template<class> class packaged_task;
template<class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)> {
public:
packaged_task() noexcept;
template<class F>
explicit packaged_task(F&& f);
~packaged_task();
packaged_task(const packaged_task&) = delete;
packaged_task& operator=(const packaged_task&) = delete;
packaged_task(packaged_task&& rhs) noexcept;
packaged_task& operator=(packaged_task&& rhs) noexcept;
void swap(packaged_task& other) noexcept;
bool valid() const noexcept;
future<R> get_future();
void operator()(ArgTypes... );
void make_ready_at_thread_exit(ArgTypes...);
void reset();
};
template<class R, class... ArgTypes>
void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
}