標準ライブラリヘッダ <future>
提供: cppreference.com
このヘッダはスレッドサポートライブラリの一部です。
クラス | ||
(C++11) | 非同期な取得のために値を格納します (クラステンプレート) | |
(C++11) | 関数をパッケージ化して、その戻り値を非同期な取得のために格納します (クラステンプレート) | |
(C++11) | 非同期に設定される値を待ちます (クラステンプレート) | |
(C++11) | (他のフューチャーからも参照される可能性がある) 非同期に設定される値を待ちます (クラステンプレート) | |
(C++11) | std::async に対する起動ポリシーを指定します (列挙) | |
(C++11) | std::future および std::shared_future で行うタイムアウト付き待機の結果を指定します (列挙) | |
(C++11) | フューチャーまたはプロミスに関するエラーを報告します (クラス) | |
(C++11) | フューチャーのエラーコードを識別します (列挙) | |
std::uses_allocator 型特性の特殊化 (クラステンプレートの特殊化) | ||
(C++11)(C++17未満) | std::uses_allocator 型特性の特殊化 (クラステンプレートの特殊化) | |
関数 | ||
(C++11) | (場合によっては新しいスレッドで) 非同期に関数を実行し、その結果を保持する std::future を返します (関数テンプレート) | |
(C++11) | フューチャーのエラーカテゴリを識別します (関数) | |
(C++11) | std::swap アルゴリズムの特殊化 (関数テンプレート) | |
std::swap アルゴリズムの特殊化 (関数テンプレート) |
[編集]概要
namespace std {enumclass future_errc { broken_promise =/* implementation-defined */, future_already_retrieved =/* implementation-defined */, promise_already_satisfied =/* implementation-defined */, no_state =/* implementation-defined */}; enumclass launch :/* unspecified */{ async =/* unspecified */, deferred =/* unspecified */, /* implementation-defined */}; enumclass future_status { ready, timeout, deferred }; template<>struct is_error_code_enum<future_errc>:public true_type {}; error_code make_error_code(future_errc e)noexcept; error_condition make_error_condition(future_errc e)noexcept; const error_category& future_category()noexcept; class future_error; template<class R>class promise;template<class R>class promise<R&>;template<>class promise<void>; template<class R>void swap(promise<R>& x, promise<R>& y)noexcept; template<class R, class Alloc>struct uses_allocator<promise<R>, Alloc>; template<class R>class future;template<class R>class future<R&>;template<>class future<void>; template<class R>class shared_future;template<class R>class shared_future<R&>;template<>class shared_future<void>; template<class>class packaged_task;// not definedtemplate<class R, class... ArgTypes>class packaged_task<R(ArgTypes...)>; template<class R, class... ArgTypes>void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&)noexcept; template<class F, class... Args>[[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>> async(F&& f, Args&&... args);template<class F, class... Args>[[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>> async(launch policy, F&& f, Args&&... args);}
[編集]クラス std::future_error
namespace std {class future_error :public logic_error {public:explicit future_error(future_errc e); const error_code& code()constnoexcept;constchar* what()constnoexcept; private: error_code ec_;// exposition only};}
[編集]クラステンプレート std::promise
namespace std {template<class R>class promise {public: promise();template<class Allocator> promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs)noexcept; promise(const promise&)= delete; ~promise(); // assignment promise& operator=(promise&& rhs)noexcept; promise& operator=(const promise&)= delete;void swap(promise& other)noexcept; // retrieving the result future<R> get_future(); // setting the resultvoid set_value(/* see description */);void set_exception(exception_ptr p); // setting the result with deferred notificationvoid set_value_at_thread_exit(/* see description */);void set_exception_at_thread_exit(exception_ptr p);}; template<class R>void swap(promise<R>& x, promise<R>& y)noexcept; template<class R, class Alloc>struct uses_allocator<promise<R>, Alloc>;}
[編集]クラステンプレート std::future
namespace std {template<class R>class future {public: future()noexcept; future(future&&)noexcept; future(const future&)= delete; ~future(); future& operator=(const future&)= delete; future& operator=(future&&)noexcept; shared_future<R> share()noexcept; // retrieving the value/* see description */ get(); // functions to check statebool valid()constnoexcept; void wait()const;template<class Rep, class Period> future_status wait_for(const chrono::duration<Rep, Period>& rel_time)const;template<class Clock, class Duration> future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time)const;};}
[編集]
namespace std {template<class R>class shared_future {public: shared_future()noexcept; shared_future(const shared_future& rhs)noexcept; shared_future(future<R>&&)noexcept; shared_future(shared_future&& rhs)noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs)noexcept; shared_future& operator=(shared_future&& rhs)noexcept; // retrieving the value/* see description */ get()const; // functions to check statebool valid()constnoexcept; void wait()const;template<class Rep, class Period> future_status wait_for(const chrono::duration<Rep, Period>& rel_time)const;template<class Clock, class Duration> future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time)const;};}
[編集]クラステンプレート std::packaged_task
namespace std {template<class>class packaged_task;// not defined template<class R, class... ArgTypes>class packaged_task<R(ArgTypes...)>{public:// construction and destruction packaged_task()noexcept;template<class F>explicit packaged_task(F&& f); ~packaged_task(); // no copy packaged_task(const packaged_task&)= delete; packaged_task& operator=(const packaged_task&)= delete; // move support packaged_task(packaged_task&& rhs)noexcept; packaged_task& operator=(packaged_task&& rhs)noexcept;void swap(packaged_task& other)noexcept; bool valid()constnoexcept; // result retrieval future<R> get_future(); // executionvoid 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;}