std::bad_expected_access

Header: <expected>

  1. Defines a type of object to be thrown by std::expected::value when accessing an expected object that contains an unexpected value. bad_expected_access stores a copy of the unexpected value.

# Declarations

template< class E >
class bad_expected_access : public std::bad_expected_access<void>

(since C++23)

template<>
class bad_expected_access<void> : public std::exception

(since C++23)

# Return value

Pointer to a null-terminated string with explanatory information. The string is suitable for conversion and display as a std::wstring. The pointer is guaranteed to be valid at least until the exception object from which it is obtained is destroyed, or until a non-const member function (e.g. copy assignment operator) on the exception object is called.

# Notes

Implementations are allowed but not required to override what().

# Example

This section is incompleteReason: no example