std::future_error
来自cppreference.com
![]() |
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <future> 中定义
|
||
class future_error; |
(since C++11) | |
。类std::future_error定义在失败时抛出一个异常对象,线程库中的功能,处理异步执行和共享状态(std::future,std::promise等)。 std::system_error,这个异常进行错误代码兼容std::error_code.
原文:
The class std::future_error defines an exception object that is thrown on failure by the functions in the thread library that deal with asynchronous execution and shared states (std::future, std::promise, etc). Similar to std::system_error, this exception carries an error code compatible with std::error_code.
目录 |
[编辑] 。成员函数。
创建一个 std::future_error 对象(公共成员函数) | |
返回的错误代码 (公共成员函数) | |
返回特定的错误代码的解释的字符串 原文: returns the explanatory string specific to the error code (公共成员函数) |
继承自 std::logic_error
继承自 std::exception
Member functions
[虚]</div></div>
|
析构该异常对象 ( std::exception 的公有虚成员函数)
|
[虚]</div></div>
|
返回一个说明字符串 ( std::exception 的公有虚成员函数)
|
</div>
[编辑] 。为例。
#include <future> #include <iostream> int main() { std::future<int> empty; try { int n = empty.get(); } 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"
[编辑] 。另请参阅。
(C++11) |
识别未来的错误代码 (枚举) |