ResultBase< T > Class Template Reference

#include <resultbase.h>

Inheritance diagram for ResultBase< T >:

Detailed Description

template<typename T>
class maxon::ResultBase< T >

Base class for Result.

Public Types

using ValueType = T
 

Public Member Functions

 ResultBase ()
 
 ResultBase (CopyType value)
 
 ResultBase (MoveType value)
 
MAXON_ATTRIBUTE_FORCE_INLINE const T & GetValue () const &
 
MAXON_ATTRIBUTE_FORCE_INLINE const T & UncheckedGetValue () const &
 
 MAXON_MEMBER_ACCESSORS (T, GetValue)
 
 MAXON_MEMBER_ACCESSORS (T, UncheckedGetValue)
 
MAXON_ATTRIBUTE_FORCE_INLINE const T & GetValueAndError (ThreadReferencedError &error) const &
 
MAXON_ATTRIBUTE_FORCE_INLINEGetValueAndError (ThreadReferencedError &error) &&
 
MAXON_ATTRIBUTE_FORCE_INLINE const T & GetValueAndError (Error &error) const &
 
MAXON_ATTRIBUTE_FORCE_INLINEGetValueAndError (Error &error) &&
 
MAXON_ATTRIBUTE_FORCE_INLINE const ThreadReferencedErrorGetErrorStorage () const
 
MAXON_ATTRIBUTE_FORCE_INLINE ThreadReferencedErrorGetErrorStorage ()
 

Static Public Attributes

static constexpr Bool HAS_ERROR
 

Protected Types

using CopyType = typename ByValueParam< T >::type
 
using MoveType = typename std::conditional< STD_IS_REPLACEMENT(reference, CopyType), T &&, DummyParamType & >::type
 
using DeleteType = const DummyParamType &&
 
template<typename T2 >
using ConstructibleFrom = std::enable_if< STD_IS_REPLACEMENT(constructible, T, T2)>
 

Protected Attributes

ThreadReferencedError _error
 
_value
 

Member Typedef Documentation

◆ ValueType

using ValueType = T

The type of the value of the Result.

◆ CopyType

using CopyType = typename ByValueParam<T>::type
protected

◆ MoveType

using MoveType = typename std::conditional<STD_IS_REPLACEMENT(reference, CopyType), T&&, DummyParamType&>::type
protected

◆ DeleteType

using DeleteType = const DummyParamType&&
protected

◆ ConstructibleFrom

using ConstructibleFrom = std::enable_if<STD_IS_REPLACEMENT(constructible, T, T2)>
protected

Constructor & Destructor Documentation

◆ ResultBase() [1/3]

◆ ResultBase() [2/3]

ResultBase ( CopyType  value)
explicit

Constructs a new ResultBase with the given value and no error.

Parameters
[in]valueResult value.

◆ ResultBase() [3/3]

ResultBase ( MoveType  value)
explicit

Constructs a new ResultBase with the given value and no error.

Parameters
[in]valueResult value.

Member Function Documentation

◆ GetValue()

MAXON_ATTRIBUTE_FORCE_INLINE const T& GetValue ( ) const &

Returns the result value. A DebugAssert will trigger if this is invoked when there is an error.

Returns
Result value.

◆ UncheckedGetValue()

MAXON_ATTRIBUTE_FORCE_INLINE const T& UncheckedGetValue ( ) const &

Returns the result value. In case of an error there is no value, then this function returns a null value.

Returns
Result value (or a null value in case of an error).

◆ MAXON_MEMBER_ACCESSORS() [1/2]

MAXON_MEMBER_ACCESSORS ( ,
GetValue   
)

◆ MAXON_MEMBER_ACCESSORS() [2/2]

MAXON_MEMBER_ACCESSORS ( ,
UncheckedGetValue   
)

◆ GetValueAndError() [1/4]

MAXON_ATTRIBUTE_FORCE_INLINE const T& GetValueAndError ( ThreadReferencedError error) const &

Returns the result value and error. If there is an error, the parameter error will be set to the error and a null value is returned.

Parameters
[out]errorThis parameter receives the error (or a nullptr if there is no error).
Returns
Result value (or a null value in case of an error).

◆ GetValueAndError() [2/4]

MAXON_ATTRIBUTE_FORCE_INLINE T GetValueAndError ( ThreadReferencedError error) &&

Returns the result value and error. If there is an error, the parameter error will be set to the error and a null value is returned.

Parameters
[out]errorThis parameter receives the error (or a nullptr if there is no error).
Returns
Result value (or a null value in case of an error).

◆ GetValueAndError() [3/4]

MAXON_ATTRIBUTE_FORCE_INLINE const T& GetValueAndError ( Error &  error) const &

Returns the result value and error. If there is an error, the parameter error will be set to the error and a null value is returned.

Parameters
[out]errorThis parameter receives the error (or a nullptr if there is no error).
Returns
Result value (or a null value in case of an error).

◆ GetValueAndError() [4/4]

MAXON_ATTRIBUTE_FORCE_INLINE T GetValueAndError ( Error &  error) &&

Returns the result value and error. If there is an error, the parameter error will be set to the error and a null value is returned.

Parameters
[out]errorThis parameter receives the error (or a nullptr if there is no error).
Returns
Result value (or a null value in case of an error).

◆ GetErrorStorage() [1/2]

MAXON_ATTRIBUTE_FORCE_INLINE const ThreadReferencedError& GetErrorStorage ( ) const

Returns a reference to the ThreadReferencedError storage in which the Result stores its error.

Returns
The ThreadReferencedError where the error (if any) is stored.

◆ GetErrorStorage() [2/2]

Returns a reference to the ThreadReferencedError storage in which the Result stores its error.

Returns
The ThreadReferencedError where the error (if any) is stored.

Member Data Documentation

◆ HAS_ERROR

constexpr Bool HAS_ERROR
staticconstexpr

◆ _error

ThreadReferencedError _error
protected

◆ _value

T _value
protected