std::future_error
科技促进发展:未来[医]误差
Defined in header | | |
---|---|---|
class future_error; | | (since C++11) |
全班std::future_error
定义一个异常对象,该异常对象在线程库中处理异步执行和共享状态%28的函数失败时抛出。std::future
,,,std::promise
,等...%29。类似于std::system_error
,此异常带有与std::error_code
...
二次
二次
继承图
成员函数
(constructor) | creates a std::future_error object (public member function) |
---|---|
code | returns the error code (public member function) |
what | returns the explanatory string specific to the error code (public member function) |
继承自STD:逻辑[医]误差
继承自STD:例外
成员函数
(destructor) virtual | destructs the exception object (virtual public member function of std::exception) |
---|---|
what virtual | returns an explanatory string (virtual public member function of std::exception) |
例
二次
#include <future>
#include <iostream>
int main()
{
std::future<int> empty;
try {
int n = empty.get( // The behavior is undefined, but
// some implementations throw std::future_error
} catch (const std::future_error& e) {
std::cout << "Caught a future_error with code \"" << e.code()
<< "\"\nMessage: \"" << e.what() << "\"\n";
}
}
二次
可能的产出:
二次
Caught a future_error with code "future:3"
Message: "No associated state"
二次
另见
future_errc (C++11) | identifies the future error codes (enum) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。