Class Acts::Result< void, E >¶
-
template<typename E>
class 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 staticsuccess
factory does not accept a value.Note
To ease usage, this
Result<void, E>
is default constructible in the ok state, whereasResult<T, E>
is not.- Template Parameters
E – The type of the error
Public Functions
-
Result() = default¶
Default constructor which initializes the result in the ok state.
-
inline Result(Result<void, E> &&other)¶
Move constructor.
- Parameters
other – The other result object, rvalue ref
-
template<typename E2>
inline Result(E2 error) noexcept¶ Constructor from error.
This implicitly requires E2 to be convertible to E.
- Template Parameters
E2 – The type of the actual error
- Parameters
error – The instance of the actual error
-
inline E &error() & noexcept¶
Returns a reference to the error stored in the result.
Note
If
res.ok()
this method will abort (noexcept)- Returns
Reference to the error
-
inline E error() && noexcept¶
Returns the error by-value.
Note
If
res.ok()
this method will abort (noexcept)- Returns
Reference to the error
-
inline bool ok() const noexcept¶
Checks whether this result is in the ok state, and no error.
- Returns
bool Whether result contains an error or not.
-
Result<void, E> &operator=(const Result<void, E> &other) = default¶
The (self) assignment operator is deleted.