The Pedigree Project
0.1
|
#include <Result.h>
Public Member Functions | |
const T & | value () const |
const E & | error () const |
bool | hasError () const |
bool | hasValue () const |
Static Public Member Functions | |
static Result< T, E > | withValue (const T &v) |
static Result< T, E > | withError (const E &e) |
Private Types | |
typedef pedigree_std::remove_reference< T >::type | BaseValueType |
Private Member Functions | |
Result (const T &v) | |
Result (const E &e, bool) | |
Private Attributes | |
T | m_Value |
E | m_Error |
bool | m_HasError |
Static Private Attributes | |
static const BaseValueType | m_DefaultValue = Result<T, E>::BaseValueType() |
Result encapsulates a typed result and an optional error in one object.
Either is valid, but both cannot be valid at the same time.
Result is useful for returning status in case of cases such as timeouts or other failures where overloading a return value (e.g. a pointer) is not a desirable action.