A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/future_error::code below:

public member function

<future>

std::future_error::code
const error_code& code() const noexcept;

Get error code

Returns the error_code object associated with the exception.

Parameters none

Return value The error_code associated with the object.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// future_error::code example:
#include <iostream>     // std::cout
#include <future>       // std::promise, std::future_error
#include <string>       // operator<<(ostream&,const string&)

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

  try {
    prom.get_future();
    prom.get_future();   // throws std::future_error
  }
  catch (std::future_error& e) {
    std::cout << "future_error caught: " << e.code().message() << '\n';
  }

  return 0;
}

Possible output (the message is implementation-specific):
future_error caught: promise already satisfied


See also
future_error::future_error
Construct future_error (public member function)
future_error::what
Get message associated to exception (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4