cf::unexpected¶
Wrapper type for constructing expected objects in error state. More...
#include <expected.hpp>
Public Functions¶
| Name | |
|---|---|
| unexpected() =delete Deleted default constructor. |
|
| template <typenameErr =E,typename =std::enable_if_t<!std::is_same_v constexpr |
unexpected(Err && e) Constructs unexpected from an error value. |
| template <typename... Args,typename =std::enable_if_t constexpr |
unexpected(std::in_place_t , Args &&... args) Constructs unexpected in-place with arguments. |
| template <typenameU ,typename... Args,typename =std::enable_if_t constexpr |
unexpected(std::in_place_t , std::initializer_list< U > il, Args &&... args) Constructs unexpected in-place with initializer list. |
| constexprconstE & | error() const Returns const reference to the error. |
| constexprE & | error() Returns reference to the error. |
| constexprconstE && | error() const Returns const rvalue reference to the error. |
| constexprE && | error() Returns rvalue reference to the error. |
| void | swap(unexpected & other) Swaps the error with another unexpected. |
Friends¶
| Name | |
|---|---|
| constexprbool | operator==(constunexpected & a, constunexpected< E2 > & b) Compares two unexpected objects for equality. |
Detailed Description¶
Wrapper type for constructing expected objects in error state.
Template Parameters:
- E Error type to wrap.
Public Functions Documentation¶
function unexpected¶
Deleted default constructor.
function unexpected¶
template <typenameErr =E,
typename =std::enable_if_t<!std::is_same_v<std::decay_t<Err>, unexpected> && std::is_constructible_v<E, Err>>>
inline explicit constexpr unexpected(
Err && e
)
Constructs unexpected from an error value.
Parameters:
- e Error value to wrap.
Template Parameters:
- Err Forwarded error type.
function unexpected¶
template <typename... Args,
typename =std::enable_if_t<std::is_constructible_v<E, Args...>>>
inline explicit constexpr unexpected(
std::in_place_t ,
Args &&... args
)
Constructs unexpected in-place with arguments.
Parameters:
- args Arguments to forward to E constructor.
Template Parameters:
- Args Constructor argument types.
function unexpected¶
template <typenameU ,
typename... Args,
typename =std::enable_if_t<std::is_constructible_v<E, std::initializer_list<U>&, Args...>>>
inline explicit constexpr unexpected(
std::in_place_t ,
std::initializer_list< U > il,
Args &&... args
)
Constructs unexpected in-place with initializer list.
Parameters:
- il Initializer list.
- args Additional arguments.
Template Parameters:
- U Element type of initializer list.
- Args Constructor argument types.
function error¶
Returns const reference to the error.
Exceptions:
- None.
Return: Const reference to the error.
function error¶
Returns reference to the error.
Exceptions:
- None.
Return: Reference to the error.
function error¶
Returns const rvalue reference to the error.
Exceptions:
- None.
Return: Const rvalue reference to the error.
function error¶
Returns rvalue reference to the error.
Exceptions:
- None.
Return: Rvalue reference to the error.
function swap¶
Swaps the error with another unexpected.
Parameters:
- other Other unexpected to swap with.
Exceptions:
- None if E is nothrow swappable.
Since: 0.1
Note: None.
Warning: None.
Friends¶
friend operator==¶
Compares two unexpected objects for equality.
Parameters:
- a First unexpected.
- b Second unexpected.
Exceptions:
- None.
Template Parameters:
- E2 Error type of the other unexpected.
Return: true if errors are equal, false otherwise.
Updated on 2026-03-09 at 10:14:00 +0000