cvw::expected<void, E>
Specialization of expected for void value type. More...
#include <expected.hpp>
Public Types
| Name | |
|---|---|
| using void | value_type Value type alias. |
| using E | error_type Error type alias. |
| using unexpected<E> | unexpected_type Unexpected type alias. |
Public Functions
| Name | |
|---|---|
| constexpr | expected() Default constructor. Creates expected in success state. |
| expected(constexpected & o) Copy constructor. | |
| expected(expected && o) Move constructor. | |
| template <typenameG =E> constexpr | expected(constunexpected<G> & u) Constructor from unexpected. |
| template <typenameG =E> constexpr | expected(unexpected<G> && u) Constructor from unexpected rvalue. |
| constexpr | expected(std::in_place_t ) In-place constructor for success state. |
| template <typename... Args> constexpr | expected(unexpect_t , Args &&... args) Constructor for in-place error construction. |
| ~expected() Destructor. | |
| expected & | operator=(constexpected & o) Copy assignment operator. |
| constexprbool | has_value() const Checks if the expected is in success state. |
| constexpr | operator bool() const Boolean conversion operator. |
| constexprvoid | value() const Returns void if in success state. |
| constexprE & | error() Returns the contained error. |
| constexprconstE & | error() const Returns the contained error (const lvalue). |
| constexprE && | error() Returns the contained error (rvalue). |
| constexprconstE && | error() const Returns the contained error (const rvalue). |
| template <typenameF > auto | and_then(F && f) Monadic operation: chains if in success state. |
| template <typenameF > auto | and_then(F && f) Monadic operation: chains if in success state (rvalue). |
| template <typenameF > auto | transform(F && f) Monadic operation: transforms the success state. |
| template <typenameF > auto | transform(F && f) Monadic operation: transforms the success state (rvalue). |
Detailed Description
template <typenameE>
class cvw::expected<void, E>;Specialization of expected for void value type.
Template Parameters:
- E Error type.
This specialization represents operations that may fail but do not produce a value on success.
Public Types Documentation
using value_type
using cvw::expected<void, E>::value_type = void;Value type alias.
using error_type
using cvw::expected<void, E>::error_type = E;Error type alias.
using unexpected_type
using cvw::expected<void, E>::unexpected_type = unexpected<E>;Unexpected type alias.
Public Functions Documentation
function expected
inline constexpr expected()Default constructor. Creates expected in success state.
Exceptions:
- None.
function expected
inline expected(
constexpected & o
)Copy constructor.
Parameters:
- o Expected to copy from.
Exceptions:
- May throw if E copy constructor throws.
function expected
inline expected(
expected && o
)Move constructor.
Parameters:
- o Expected to move from.
Exceptions:
- May throw if E move constructor throws.
function expected
template <typenameG =E>
inline constexpr expected(
constunexpected<G> & u
)Constructor from unexpected.
Parameters:
- u Unexpected value containing error.
Exceptions:
- May throw if E constructor throws.
Template Parameters:
- G Forwarded error type.
function expected
template <typenameG =E>
inline constexpr expected(
unexpected<G> && u
)Constructor from unexpected rvalue.
Parameters:
- u Unexpected value containing error.
Exceptions:
- May throw if E constructor throws.
Template Parameters:
- G Forwarded error type.
function expected
inline explicit constexpr expected(
std::in_place_t
)In-place constructor for success state.
Exceptions:
- None.
function expected
template <typename... Args>
inline explicit constexpr expected(
unexpect_t ,
Args &&... args
)Constructor for in-place error construction.
Parameters:
- args Arguments to forward to E constructor.
Exceptions:
- May throw if E constructor throws.
Template Parameters:
- Args Constructor argument types.
function ~expected
inline ~expected()Destructor.
Exceptions:
- None.
function operator=
inline expected & operator=(
constexpected & o
)Copy assignment operator.
Parameters:
- o Expected to copy from.
Exceptions:
- May throw if E assignment or construction throws.
Return: Reference to this expected.
function has_value
inline constexprbool has_value() constChecks if the expected is in success state.
Exceptions:
- None.
Return: true if in success state, false if in error state.
function operator bool
inline explicit constexpr operator bool() constBoolean conversion operator.
Exceptions:
- None.
Return: true if in success state, false if in error state.
function value
inline constexprvoid value() constReturns void if in success state.
Exceptions:
- bad_expected_access if in error state.
Warning: Throws bad_expected_access if this expected contains an error.
function error
inline constexprE & error()Returns the contained error.
Exceptions:
- None.
Return: Reference to the contained error.
Warning: The error is only valid if has_value() returns false.
function error
inline constexprconstE & error() constReturns the contained error (const lvalue).
Exceptions:
- None.
Return: Const reference to the contained error.
Warning: The error is only valid if has_value() returns false.
function error
inline constexprE && error()Returns the contained error (rvalue).
Exceptions:
- None.
Return: Rvalue reference to the contained error.
Warning: The error is only valid if has_value() returns false.
function error
inline constexprconstE && error() constReturns the contained error (const rvalue).
Exceptions:
- None.
Return: Const rvalue reference to the contained error.
Warning: The error is only valid if has_value() returns false.
function and_then
template <typenameF>
inline auto and_then(
F && f
)Monadic operation: chains if in success state.
Parameters:
- f Function to call if in success state.
Exceptions:
- None.
Template Parameters:
- F Callable type.
Return: Result of f() or error.
function and_then
template <typenameF>
inline auto and_then(
F && f
)Monadic operation: chains if in success state (rvalue).
Parameters:
- f Function to call if in success state.
Exceptions:
- None.
Template Parameters:
- F Callable type.
Return: Result of f() or error.
function transform
template <typenameF>
inline auto transform(
F && f
)Monadic operation: transforms the success state.
Parameters:
- f Function to apply.
Exceptions:
- None.
Template Parameters:
- F Callable type.
Return: expected with transformed value or error.
function transform
template <typenameF>
inline auto transform(
F && f
)Monadic operation: transforms the success state (rvalue).
Parameters:
- f Function to apply.
Exceptions:
- None.
Template Parameters:
- F Callable type.
Return: expected with transformed value or error.
Updated on 2026-05-17 at 13:22:38 +0000