Lely core libraries
2.3.4
|
A type capable of representing both the successful and failure result of an operation. More...
#include <result.hpp>
Public Types | |
using | value_type = T |
The value type on success. | |
using | error_type = typename error_traits::error_type |
The error type on failure. | |
Public Member Functions | |
Result ()=default | |
Constructs a successful result with an empty value. | |
Result (const detail::Success< void > &) | |
Constructs a successful result with an empty value. More... | |
template<class U > | |
Result (const detail::Success< U > &s) | |
Constructs a successful result with the specified value. More... | |
template<class U > | |
Result (detail::Success< U > &&s) | |
Constructs a successful result with the specified value. More... | |
template<class U > | |
Result (const detail::Failure< U > &f) | |
Constructs a failure result with the specified error. More... | |
template<class U > | |
Result (detail::Failure< U > &&f) | |
Constructs a failure result with the specified error. More... | |
template<class U > | |
Result (U &&u, typename ::std::enable_if< ::std::is_constructible< value_type, U >::value &&!::std::is_constructible< error_type, U >::value, bool >::type=false) | |
Constructs a successful result with value u if U is constructible to value_type and not constructible to error_type. | |
template<class U > | |
Result (U &&u, typename ::std::enable_if< !::std::is_constructible< value_type, U >::value &&::std::is_constructible< error_type, U >::value, bool >::type=false) | |
Constructs a failure result with error u if U is constructible to error_type and not constructible to value_type. | |
operator bool () const noexcept | |
Check whether *this contains a value (and not a non-zero error). | |
bool | has_value () const noexcept |
Returns true if *this contains a value (and not a non-zero error). More... | |
value_type & | value () |
Returns a reference to the value if *this contains a value, and throws an exception if *this contains a non-zero error. | |
const value_type & | value () const |
Returns a reference to the value if *this contains a value, and throws an exception if *this contains a non-zero error. | |
bool | has_error () const noexcept |
Returns true if *this contains a non-zero error. More... | |
error_type & | error () noexcept |
Returns a reference to the error, if any. | |
const error_type & | error () const noexcept |
Returns a reference to the error, if any. | |
A type capable of representing both the successful and failure result of an operation.
Definition at line 200 of file result.hpp.
|
inline |
Constructs a successful result with an empty value.
Definition at line 214 of file result.hpp.
|
inline |
Constructs a successful result with the specified value.
Definition at line 218 of file result.hpp.
|
inline |
Constructs a successful result with the specified value.
Definition at line 222 of file result.hpp.
|
inline |
Constructs a failure result with the specified error.
Definition at line 226 of file result.hpp.
|
inline |
Constructs a failure result with the specified error.
Definition at line 230 of file result.hpp.
|
inlinenoexcept |
Returns true if *this
contains a value (and not a non-zero error).
Definition at line 265 of file result.hpp.
|
inlinenoexcept |
Returns true if *this
contains a non-zero error.
Definition at line 291 of file result.hpp.