The Pedigree Project 0.1
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Result< T, E > Class Template Reference

#include <Result.h>

+ Collaboration diagram for Result< T, E >:

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
 

Detailed Description

template<class T, class E>
class Result< T, E >

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.

Definition at line 36 of file Result.h.

Member Typedef Documentation

◆ BaseValueType

template<class T , class E >
typedef pedigree_std::remove_reference<T>::type Result< T, E >::BaseValueType
private

Definition at line 75 of file Result.h.

Constructor & Destructor Documentation

◆ Result() [1/2]

template<class T , class E >
Result< T, E >::Result ( const T &  v)
inlineprivate

Definition at line 67 of file Result.h.

◆ Result() [2/2]

template<class T , class E >
Result< T, E >::Result ( const E &  e,
bool   
)
inlineprivate

Definition at line 69 of file Result.h.

Member Function Documentation

◆ error()

template<class T , class E >
const E & Result< T, E >::error ( ) const
inline

Definition at line 51 of file Result.h.

◆ hasError()

template<class T , class E >
bool Result< T, E >::hasError ( ) const
inline

Definition at line 56 of file Result.h.

◆ hasValue()

template<class T , class E >
bool Result< T, E >::hasValue ( ) const
inline

Definition at line 60 of file Result.h.

◆ value()

template<class T , class E >
const T & Result< T, E >::value ( ) const
inline

Definition at line 46 of file Result.h.

◆ withError()

template<class T , class E >
static Result< T, E > Result< T, E >::withError ( const E &  e)
inlinestatic

Definition at line 42 of file Result.h.

◆ withValue()

template<class T , class E >
static Result< T, E > Result< T, E >::withValue ( const T &  v)
inlinestatic

Definition at line 38 of file Result.h.

Member Data Documentation

◆ m_DefaultValue

template<class T , class E >
const Result< T, E >::BaseValueType Result< T, E >::m_DefaultValue
staticprivate
Initial value:
=
Result<T, E>::BaseValueType()

Definition at line 76 of file Result.h.

◆ m_Error

template<class T , class E >
E Result< T, E >::m_Error
private

Definition at line 72 of file Result.h.

◆ m_HasError

template<class T , class E >
bool Result< T, E >::m_HasError
private

Definition at line 73 of file Result.h.

◆ m_Value

template<class T , class E >
T Result< T, E >::m_Value
private

Definition at line 71 of file Result.h.


The documentation for this class was generated from the following file: