标准库标头<future> 此头文件是线程支持库的一部分。 类 promise (C++11) 存储一个值以进行异步获取 (类模板) packaged_task (C++11) 打包一个函数,存储其返回值以进行异步获取 (类模板) future (C++11) 等待被异步设置的值 (类模板) shared_future ...
类模板std::future提供访问异步操作结果的机制: (通过std::async、std::packaged_task或std::promise创建的)异步操作能提供一个std::future对象给该异步操作的创建者。 然后,异步操作的创建者可以使用多个方法查询、等待或从std::future提取值。若异步操作尚未提供值,则这些方法可能阻塞。
future::valid future::wait future::wait_for future::wait_untilfuture() noexcept; (1) (since C++11) future( future&& other ) noexcept; (2) (since C++11) future( const future& other ) = delete; (3) (since C++11) Constructs a std::future object. 1...
Planned Maintenance The site will be in a temporary read-only mode in the next few weeks to facilitate some long-overdue software updates. We apologize for any inconvenience this may cause! C++ reference C++11,C++14,C++17,C++20,C++23,C++26│Compiler supportC++11,C++14,C++17,C++20,C++23,C+...
future_error::future_error future_error::operator= future_error::code future_error::what 1)Copy constructor. Initializes the contents of the newfuture_errorobject with those ofother. If*thisandotherboth have dynamic typestd::future_errorthenstd::strcmp(what(), other.what())==0. ...
std::async 是C++11 引入的一个函数模板,用于异步地执行一个函数,并返回一个 std::future 对象,该对象可用于获取函数的执行结果。 2. 参数 std::async 有两个主要的参数形式: std::future<typename std::result_of<F(Args...)>::type> async(F&& f, Args&&... ...
std::future<typenamestd::result_of<Function(Args...)>::type> async(std::launchpolicy, Function&&f, Args&&...args); (2)(seit C++11) Die Template-Funktionasyncführt die Funktionfasynchron (möglicherweise in einem separaten Thread) und gibt einenstd::future, die schließlich halten ...
The storage of the vector is handled automatically, being expanded as needed. Vectors usually occupy more space than static arrays, because more memory is allocated to handle future growth. This way a vector does not need to reallocate each time an element is inserted, but only when the additi...
requirementsbeforetemplate instantiation and in turn could produce much more sensible error messages in case a type did not fulfill the template requirements. This proposal was later dropped for various reasons. However, there are unofficial plans to add concepts to a future revision of the C++ ...
Wenn der asynchrone Vorgang bereit ist, dem Auslöser ein Ergebnis bereitzustellen, kann es dies durch Änderung desgemeinsamen Zustandstun (z.B.std::promise::set_value), der mit demstd::futuredes Auslösers verbunden ist. Beachten Sie, dassstd::futureeinen gemeinsamen Zustand referenz...