Files
2025-10-25 03:02:53 +03:00

68 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[expected.bad]
# 22 General utilities library [[utilities]](./#utilities)
## 22.8 Expected objects [[expected]](expected#bad)
### 22.8.4 Class template bad_expected_access [expected.bad]
[🔗](#lib:bad_expected_access)
namespace std {template<class E>class bad_expected_access : public bad_expected_access<void> {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](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7918)
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[.](#1.sentence-1)
[🔗](#lib:bad_expected_access,constructor)
`constexpr explicit bad_expected_access(E e);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7930)
*Effects*: Initializes *unex* with std::move(e)[.](#2.sentence-1)
[🔗](#lib:error,bad_expected_access)
`constexpr const E& error() const & noexcept;
constexpr E& error() & noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7942)
*Returns*: *unex*[.](#3.sentence-1)
[🔗](#lib:error,bad_expected_access_)
`constexpr E&& error() && noexcept;
constexpr const E&& error() const && noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7954)
*Returns*: std::move(*unex*)[.](#4.sentence-1)
[🔗](#lib:what,bad_expected_access)
`constexpr const char* what() const noexcept override;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7965)
*Returns*: An implementation-defined ntbs,
which during constant evaluation is encoded with
the ordinary literal encoding ([[lex.ccon]](lex.ccon "5.13.3Character literals"))[.](#5.sentence-1)