function
<future>

std::make_error_condition (future_errc)

error_code make_error_condition (future_errc e) noexcept;
Make error condition
Creates an error_condition object from the future_errc enum value e (of the future_category).

It returns the same as
1
error_condition(static_cast<int>(e),future_category());

This overload is called by error_condition's constructor when passed an argument of type future_errc.

Parameters

e
An enum value of type future_errc.

Return value

An error_condition object representing the enum value e.

Example

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

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

  try {
    prom.get_future();
    prom.get_future();   // throws std::future_error with future_already_retrieved
  }
  catch (std::future_error& e) {
    if (e.code() == std::make_error_condition(std::future_errc::future_already_retrieved))
    std::cerr << "[future already retrieved]\n";
    else std::cerr << "[unknown exception]\n";
  }

  return 0;
}

Output (stderr):

[future already retrieved]


Exception safety

No-throw guarantee: this function never throws exceptions.

See also