std::bad_expected_access
<expected>
class bad_expected_access : public std::bad_expected_access<void>
class bad_expected_access<void> : public std::exception
bad_expected_access<E>
stores a copy of the unexpected value.bad_expected_access
specializations.std::bad_expected_access
are constexpr: it is possible to create and use std::bad_expected_access
objects in the evaluation of a constant expression.However, std::bad_expected_access
objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression.
Reason: inheritance diagram
Contents
[edit] Members of the primary template
bad_expected_access
object (public member function)
(public member function)
(public member function)
std::bad_expected_access::bad_expected_access
(constexpr since C++26)
Constructs a new bad_expected_access<E>
object. Initializes the stored value with std::move(e)
.
std::bad_expected_access::error
(constexpr since C++26)
(constexpr since C++26)
(constexpr since C++26)
(constexpr since C++26)
Returns a reference to the stored value.
std::bad_expected_access::what
(constexpr since C++26)
Returns the explanatory string.
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.
The returned string is encoded with the ordinary literal encoding during constant evaluation.
(since C++26)Notes
Implementations are allowed but not required to override what()
.
Inherited from std::bad_expected_access<void>
Members of the bad_expected_access<void> specialization
(protected member function)
(protected member function)
(protected member function)
(public member function)
Special member functions of bad_expected_access<void> are protected. They can only be called by derived classes.
Inherited from std::exception
Member functions
[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_constexpr_exceptions |
202502L |
(C++26) | constexpr std::bad_expected_access
|
[edit] Example
Reason: no example
[edit] See also
(class) [edit]