|
|
| 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.
|
template<typename E>
class Acts::Result< void, E >
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.
- Note
- To ease usage, this Result<void, E> is default constructible in the ok state, whereas Result<T, E> is not.
- Template Parameters
-
| 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>.
- Parameters
-
| [in] | callable | The transformation function to apply. |
- Note
- This is the lvalue version.
-
This functions is >>= on the functor in A of Result<A, E>.
- Returns
- The modified valid value if exists, or an error otherwise.