|
ACTS
Experiment-independent tracking
|
Template specialization for the void case. More...
#include <Acts/Utilities/Result.hpp>
Public Types | |
| using | ErrorType = E |
| Type alias for the error type contained in failed result. | |
| using | ValueType = void |
| Type alias for the value type (void) in successful result. | |
Public Member Functions | |
| Result ()=default | |
| Default constructor which initializes the result in the ok state. | |
| Result (const Result< void, E > &other)=default | |
| The copy constructor is deleted. | |
| template<typename E2> | |
| Result (E2 error) noexcept | |
| Constructor from error. | |
| Result (Result< void, E > &&other) noexcept | |
| Move constructor. | |
| auto | and_then (C &&callable) const & |
| Bind a function to this result monadically. | |
| E | error () &&noexcept |
| Returns the error by-value. | |
| E & | error () &noexcept |
| Returns a reference to the error stored in the result. | |
| const E & | error () const &noexcept |
| Returns a reference to the error stored in the result. | |
| bool | ok () const noexcept |
| Checks whether this result is in the ok state, and no error. | |
| void & | operator* () noexcept |
| Returns a reference into the variant to the valid value. | |
| void * | operator-> () noexcept |
| Allows to access members of the stored object with res->foo similar to std::optional. | |
| Result< void, E > & | operator= (const Result< void, E > &other)=default |
| The (self) assignment operator is deleted. | |
| template<typename E2> | |
| Result< void, E > & | operator= (E2 error) |
| Assignment operator from an error. | |
| Result< void, E > & | operator= (Result< void, E > &&other) noexcept |
| Move assignment operator. | |
| auto | transform (C &&callable) const & |
| Transforms the value contained in this result. | |
| void | value () const |
| Validates this void result and throws if an error is present. | |
| std::conditional_t< std::is_reference_v< U >, const void &, void > | value_or (U &&v) const & |
| Retrieves the valid value from the result object, or returns a default value if no valid value exists. | |
Static Public Member Functions | |
| static Result< void, E > | failure (E error) |
| Static factory function to initialize the result in the error state. | |
| static Result< void, E > | success () |
| Static factory function to initialize the result in the ok state. | |
Template specialization for the void case.
This specialization handles the case where there is no actual return value, but an error might be returned. Returning the error directly would make handling different from other functions using the Result<T, E> mechanism. Result<void, E> does not have the dereference operator, and value methods. The static success factory does not accept a value.
| E | The type of the error |
| using Acts::Result< void, E >::ErrorType = E |
Type alias for the error type contained in failed result.
| using Acts::Result< void, E >::ValueType = void |
Type alias for the value type (void) in successful result.
|
default |
Default constructor which initializes the result in the ok state.
|
default |
The copy constructor is deleted.
| other | The other result instance to copy from |
|
noexcept |
Move constructor.
| other | The other result object, rvalue ref |
Constructor from error.
This implicitly requires E2 to be convertible to E.
| E2 | The type of the actual error |
| error | The instance of the actual error |
| auto Acts::Result< void, E >::and_then | ( | C && | callable | ) | const & |
Bind a function to this result monadically.
This function takes a function f and, if this result contains a valid value x, returns f(x). If the type of x is T, then f is expected to accept type T and return Result<U>. In this case, transform would return the unhelpful type Result<Result<U>>, so and_then strips away the outer layer to return Result<U>. If the value is invalid, this returns an invalid value in Result<U>.
| [in] | callable | The transformation function to apply. |
|
noexcept |
Returns the error by-value.
|
noexcept |
Returns a reference to the error stored in the result.
|
noexcept |
Returns a reference to the error stored in the result.
|
static |
Static factory function to initialize the result in the error state.
| error | The error to initialize with. |
|
noexcept |
Checks whether this result is in the ok state, and no error.
|
noexcept |
Returns a reference into the variant to the valid value.
|
noexcept |
Allows to access members of the stored object with res->foo similar to std::optional.
|
default |
The (self) assignment operator is deleted.
| other | The other result instance to assign from |
| Result< void, E > & Acts::Result< void, E >::operator= | ( | E2 | error | ) |
Assignment operator from an error.
| E2 | The type of the actual error |
| error | The instance of the actual error |
|
noexcept |
Move assignment operator.
| other | The other result object, rvalue ref |
|
static |
Static factory function to initialize the result in the ok state.
| auto Acts::Result< void, E >::transform | ( | C && | callable | ) | const & |
Transforms the value contained in this result.
Applying a function f to a valid value x returns f(x), while applying f to an invalid value returns another invalid value.
| [in] | callable | The transformation function to apply. |
| void Acts::Result< void, E >::value | ( | ) | const |
Validates this void result and throws if an error is present.
This method checks if the result contains an error and throws an exception if one is found. For void results, there is no value to return - this method only performs validation.
| std::runtime_error | if the result contains an error |
| std::conditional_t< std::is_reference_v< U >, const void &, void > Acts::Result< void, E >::value_or | ( | U && | v | ) | const & |
Retrieves the valid value from the result object, or returns a default value if no valid value exists.
| [in] | v | The default value to use if no valid value exists. |