Reference

public member function
<future>

std::future_error::what

const char* what() const noexcept;
Get message associated to exception
Returns the message that describes the exception.

This message includes the string returned by code().message() .

Parameters

none

Return value

A C-string with the message describing the exception.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// future_error::what example:
#include <iostream> // std::cout
#include <future> // std::promise, std::future_error
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.what() << '\n';
 }
 return 0;
}

Possible output (the message is implementation-specific):

future_error caught: promise already satisfied


See also

future_error::code
Get error code (public member function)

AltStyle によって変換されたページ (->オリジナル) /