|
Porytiles
|
Template specialization of ChainableResult for void success type. More...
#include <chainable_result.hpp>
Public Member Functions | |
| ChainableResult () | |
| Default constructor creating a successful void result. | |
| ChainableResult (const E &error) | |
| Constructs a ChainableResult from an error value. | |
| template<typename CauseT , typename CauseE > | |
| ChainableResult (const E &error, const ChainableResult< CauseT, CauseE > &cause_result) | |
| Constructs a ChainableResult by chaining a new error with an existing error chain. | |
| void | value () & |
| Accesses the void success value. | |
| void | value () const & |
| Accesses the void success value (const version). | |
| void | value () && |
| Accesses the void success value (rvalue version). | |
Public Member Functions inherited from porytiles2::ChainableResult< detail::Empty, E > | |
| ChainableResult (detail::Empty value) | |
| Constructs a ChainableResult from a success value. | |
| ChainableResult (const E &error) | |
| Constructs a ChainableResult from an error value. | |
| ChainableResult (const E &error, const ChainableResult< CauseT, CauseE > &cause_result) | |
| Constructs a ChainableResult by chaining a new error with an existing error chain. | |
| ChainableResult (ChainableResult &&)=default | |
| ChainableResult (const ChainableResult &)=delete | |
| ChainableResult & | operator= (ChainableResult &&)=default |
| ChainableResult & | operator= (const ChainableResult &)=delete |
| void | add_cause (const ChainableResult< OtherT, OtherE > &cause_result) |
| Adds all errors from another ChainableResult's chain to this result's chain. | |
| bool | has_value () const |
| Checks whether the result contains a success value. | |
| detail::Empty & | value () & |
| Returns a reference to the contained success value. | |
| const detail::Empty & | value () const & |
| Returns a const reference to the contained success value. | |
| detail::Empty && | value () && |
| Returns an rvalue reference to the contained success value. | |
| const E & | error () const |
| Returns a const reference to the immediate error. | |
| const std::vector< std::unique_ptr< Error > > & | chain () const |
| Returns the complete error chain. | |
Additional Inherited Members | |
Protected Member Functions inherited from porytiles2::ChainableResult< detail::Empty, E > | |
| ChainableResult ()=default | |
Template specialization of ChainableResult for void success type.
This specialization handles the case where no value needs to be returned on success, similar to std::expected<void, E>. It is implemented as a thin wrapper around the primary template, using a private detail::Empty struct as a placeholder for the void type. This approach avoids code duplication while providing a void-like interface.
| E | The error type, must be derived from Error interface |
Definition at line 225 of file chainable_result.hpp.
|
inline |
Default constructor creating a successful void result.
Constructs a ChainableResult representing success with no value. This allows functions returning ChainableResult<void, E> to use the syntax return {} for successful completion.
Definition at line 237 of file chainable_result.hpp.
|
inline |
Constructs a ChainableResult from an error value.
This constructor allows implicit conversion from an error value of type E to a ChainableResult. The error is stored as the initial error in the chain. This provides ergonomic construction for error cases at the bottom level of an error chain.
| error | The error value to store |
Definition at line 249 of file chainable_result.hpp.
|
inlineexplicit |
Constructs a ChainableResult by chaining a new error with an existing error chain.
This constructor creates a new error result that includes both a new error message and the complete error chain from a cause result. This is the primary mechanism for building error context as errors propagate up through application layers. The new error is added to the beginning of the chain, followed by all errors from the cause result's chain.
| CauseT | The success type of the cause result (may be void) |
| CauseE | The error type of the cause result, must be derived from Error |
| error | The new error to add at this level |
| cause_result | The ChainableResult containing the error chain to chain |
Definition at line 266 of file chainable_result.hpp.
|
inline |
Accesses the void success value.
For the void specialization, this method returns void and simply validates that the result is indeed a success. It will throw std::bad_expected_access if called when the result contains an error.
Definition at line 279 of file chainable_result.hpp.
|
inline |
Accesses the void success value (rvalue version).
For the void specialization, this method returns void and simply validates that the result is indeed a success when called on an rvalue ChainableResult. It will throw std::bad_expected_access if called when the result contains an error.
Definition at line 305 of file chainable_result.hpp.
|
inline |
Accesses the void success value (const version).
For the void specialization, this method returns void and simply validates that the result is indeed a success. It will throw std::bad_expected_access if called when the result contains an error.
Definition at line 292 of file chainable_result.hpp.