22 General utilities library [utilities]

22.8 Expected objects [expected]

22.8.4 Class template bad_­expected_­access [expected.bad]

namespace std { template<class E> class bad_expected_access : public bad_expected_access<void> { public: explicit bad_expected_access(E); const char* what() const noexcept override; E& error() & noexcept; const E& error() const & noexcept; E&& error() && noexcept; const E&& error() const && noexcept; private: E val; // exposition only }; }
The class template bad_­expected_­access defines the type of objects thrown as exceptions to report the situation where an attempt is made to access the value of an expected<T, E> object for which has_­value() is false.
explicit bad_expected_access(E e);
Effects: Initializes val with std​::​move(e).
const E& error() const & noexcept; E& error() & noexcept;
Returns: val.
E&& error() && noexcept; const E&& error() const && noexcept;
Returns: std​::​move(val).
const char* what() const noexcept override;
Returns: An implementation-defined ntbs.