Files
cppdraft_translate/cppdraft/expected/bad.md
2025-10-25 03:02:53 +03:00

2.2 KiB
Raw Blame History

[expected.bad]

22 General utilities library [utilities]

22.8 Expected objects [expected]

22.8.4 Class template bad_expected_access [expected.bad]

🔗

namespace std {templateclass bad_expected_access : public bad_expected_access {public:constexpr explicit bad_expected_access(E); constexpr const char* what() const noexcept override; constexpr E& error() & noexcept; constexpr const E& error() const & noexcept; constexpr E&& error() && noexcept; constexpr const E&& error() const && noexcept; private: E unex; // exposition only};}

1

#

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.

🔗

constexpr explicit bad_expected_access(E e);

2

#

Effects: Initializes unex with std::move(e).

🔗

constexpr const E& error() const & noexcept; constexpr E& error() & noexcept;

3

#

Returns: unex.

🔗

constexpr E&& error() && noexcept; constexpr const E&& error() const && noexcept;

4

#

Returns: std::move(unex).

🔗

constexpr const char* what() const noexcept override;

5

#

Returns: An implementation-defined ntbs, which during constant evaluation is encoded with the ordinary literal encoding ([lex.ccon]).