|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Wrapper for the error value used to initialize an expected.
More...
#include <ah-cpp-compat.H>
Public Member Functions | |
| template<class Err = E> requires (not std::is_same_v<std::remove_cvref_t<Err>, unexpected> and std::is_constructible_v<E, Err>) | |
| constexpr | unexpected (Err &&e) noexcept(std::is_nothrow_constructible_v< E, Err >) |
Construct the stored error from any value convertible to E. | |
| constexpr const E & | error () const &noexcept |
| Access the error (const lvalue). | |
| constexpr E & | error () &noexcept |
| Access the error (lvalue). | |
| constexpr E && | error () &&noexcept |
| Access the error (rvalue). | |
Private Attributes | |
| E | err_ |
Wrapper for the error value used to initialize an expected.
Represents an error in contexts where expected is used. Construct an unexpected to return an error from a function returning expected<T,E>:
| E | Error type (must be movable). |
E construction throws, the object is not constructed.Definition at line 182 of file ah-cpp-compat.H.
|
inlineexplicitconstexprnoexcept |
Construct the stored error from any value convertible to E.
Mirrors std::unexpected's actual converting constructor: a single constrained, perfectly-forwarding constructor instead of separate const E& / E&& overloads. Two fixed overloads force the compiler to pick between them when the argument needs a user-defined conversion (e.g. building unexpected<std::string> from a string literal), which some MSVC versions fail to resolve (error C2672); a single template leaves exactly one candidate.
| Err | Deduced argument type. |
| e | Value used to construct the stored error. |
| Any | exception thrown by constructing E from e. |
Definition at line 204 of file ah-cpp-compat.H.
|
inlineconstexprnoexcept |
Access the error (rvalue).
Definition at line 224 of file ah-cpp-compat.H.
References Aleph::unexpected< E >::err_.
|
inlineconstexprnoexcept |
Access the error (lvalue).
Definition at line 218 of file ah-cpp-compat.H.
References Aleph::unexpected< E >::err_.
|
inlineconstexprnoexcept |
Access the error (const lvalue).
Definition at line 212 of file ah-cpp-compat.H.
References Aleph::unexpected< E >::err_.
|
private |
Definition at line 184 of file ah-cpp-compat.H.
Referenced by Aleph::unexpected< E >::error(), Aleph::unexpected< E >::error(), and Aleph::unexpected< E >::error().