68 lines
2.2 KiB
Markdown
68 lines
2.2 KiB
Markdown
[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.3 Character literals"))[.](#5.sentence-1)
|