std::future_errc

定义于头文件 <future>
enum class future_errc {

    broken_promise             = /* implementation-defined */,
    future_already_retrieved   = /* implementation-defined */,
    promise_already_satisfied  = /* implementation-defined */,
    no_state                   = /* implementation-defined */

};
(C++11 起)

有作用域枚举 std::future_errc 定义 std::future 及相关类于 std::future_error 异常对象中报告的错误码。只要求四个错误码,尽管实现可以定义额外的错误码。因为提供了 std::is_error_code_enum 的恰当特化,故 std::future_errc 类型值可隐式转换为 std::error_code

所有错误码均相异且非零。 (C++14 起)

目录

成员常量

常量 解释
broken_promise 异步任务抛弃其共享状态
future_already_retrieved 共享状态的内容已通过 std::future 访问
promise_already_satisfied 试图两次存储值于共享状态
no_state 试图访问无关联共享状态的 std::promisestd::future

非成员函数

构造一个 future error_code
(函数)
构造一个 future error_condition
(函数)

帮助类

扩展类型特性 std::is_error_code_enum 以鉴别 future 错误码
(类模板)

注意

C++11 中, broken_promise 曾被指定等于零,不在意 std::error_code/std::error_condition 用零表示“无错误”。这在 C++14 中得到修正。

示例

参阅

(C++11)
保有依赖平台的错误码
(类)
保有可移植的错误码
(类)

版本历史

  • (当前 | 先前 2017年8月26日 (六) 18:45Fruderica讨论 | 贡献. . (1,978字节) (-386). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 11:31P12bot讨论 | 贡献 . . (2,364字节) (-167). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 19:55P12bot讨论 | 贡献 . . (2,531字节) (+241). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 03:08P12讨论 | 贡献 . . (2,290字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (2,290字节) (+2,290). . (Translated from the English version using Google Translate)