cf::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¶
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¶
Value type alias.
using error_type¶
Error type alias.
using unexpected_type¶
Unexpected type alias.
Public Functions Documentation¶
function expected¶
Default constructor. Creates expected in success state.
Exceptions:
- None.
function expected¶
Copy constructor.
Parameters:
- o Expected to copy from.
Exceptions:
- May throw if E copy constructor throws.
function expected¶
Move constructor.
Parameters:
- o Expected to move from.
Exceptions:
- May throw if E move constructor throws.
function expected¶
Constructor from unexpected.
Parameters:
- u Unexpected value containing error.
Exceptions:
- May throw if E constructor throws.
Template Parameters:
- G Forwarded error type.
function expected¶
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¶
In-place constructor for success state.
Exceptions:
- None.
function expected¶
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¶
Destructor.
Exceptions:
- None.
function operator=¶
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¶
Checks if the expected is in success state.
Exceptions:
- None.
Return: true if in success state, false if in error state.
function operator bool¶
Boolean conversion operator.
Exceptions:
- None.
Return: true if in success state, false if in error state.
function value¶
Returns 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¶
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¶
Returns 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¶
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¶
Returns 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¶
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¶
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¶
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¶
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-03-09 at 10:14:00 +0000