Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::unexpected< E > Class Template Reference

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_
 

Detailed Description

template<class E>
class Aleph::unexpected< E >

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>:

expected<int, std::string> parse(const std::string &s) {
if (bad) return unexpected<std::string>("parse error");
return value;
}
size_t size_t int32_t value
Definition ca-c-api.h:116
Minimal std::expected-style result type for C++20.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
Template Parameters
EError type (must be movable).
Exception Safety
Basic guarantee: if E construction throws, the object is not constructed.
Thread Safety
Value type with no shared state. Operations on distinct objects are safe.

Definition at line 182 of file ah-cpp-compat.H.

Constructor & Destructor Documentation

◆ unexpected()

template<class E >
template<class Err = E>
requires (not std::is_same_v<std::remove_cvref_t<Err>, unexpected> and std::is_constructible_v<E, Err>)
constexpr Aleph::unexpected< E >::unexpected ( Err &&  e)
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.

Template Parameters
ErrDeduced argument type.
Parameters
eValue used to construct the stored error.
Exceptions
Anyexception thrown by constructing E from e.

Definition at line 204 of file ah-cpp-compat.H.

Member Function Documentation

◆ error() [1/3]

template<class E >
constexpr E && Aleph::unexpected< E >::error ( ) &&
inlineconstexprnoexcept

Access the error (rvalue).

Returns
Rvalue reference to the stored error.
Complexity O(1).

Definition at line 224 of file ah-cpp-compat.H.

References Aleph::unexpected< E >::err_.

◆ error() [2/3]

template<class E >
constexpr E & Aleph::unexpected< E >::error ( ) &
inlineconstexprnoexcept

Access the error (lvalue).

Returns
Mutable reference to the stored error.
Complexity O(1).

Definition at line 218 of file ah-cpp-compat.H.

References Aleph::unexpected< E >::err_.

◆ error() [3/3]

template<class E >
constexpr const E & Aleph::unexpected< E >::error ( ) const &
inlineconstexprnoexcept

Access the error (const lvalue).

Returns
Const reference to the stored error.
Complexity O(1).

Definition at line 212 of file ah-cpp-compat.H.

References Aleph::unexpected< E >::err_.

Member Data Documentation

◆ err_

template<class E >
E Aleph::unexpected< E >::err_
private

The documentation for this class was generated from the following file: