函式
<future>

std::future_category

const error_category& future_category() noexcept;
返回 future 類別
返回一個指向具有以下特徵的 `error_category` 型別靜態物件的引用。

與此類別關聯的是描述與列舉型別 future_errc 相對應的錯誤的 error_condition 物件。何謂其中一個這種對應關係取決於作業系統和特定的庫實現。

引數



返回值

future error_category 物件的引用。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// std::future_category example:
#include <iostream>     // std::cerr
#include <future>       // std::promise, std::future_error, std::future_category

int main ()
{
  std::promise<int> prom;

  try {
    prom.get_future();
    prom.get_future();   // throws a std::future_error of the future category
  }
  catch (std::future_error& e) {
    if (e.code().category() == std::future_category())
    std::cerr << "future_error of the future category thrown\n";
  }

  return 0;
}

輸出 (到 stderr)

future_error of the future category thrown


異常安全

無異常保證:此函式從不丟擲異常。

另見