function
<future>

std::future_category

const error_category& future_category() noexcept;
Return future category
Returns a reference to the static object of the error_category type that has the following characteristics:

error_condition objects describing errors that correspond to the enum type future_errc are associated to this category. What constitutes one of these correspondences depends on the operating system and the particular library implementation.

Parameters

none

Return value

A reference to the future error_category object.

Example

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;
}

Output (on stderr):

future_error of the future category thrown


Exception safety

No-throw guarantee: this function never throws exceptions.

See also