ResultMemT< T > Class Template Reference

#include <resultbase.h>

Detailed Description

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

ResultMemT can be used as return type of functions which normally return a T, but might fail only due to an out-of-memory situation and indicate this by the null value of T. The typical use-case is for pointers or strong/unique references. You can't use ResultMemT when the null value of T shall be a legal return value of the function, in that case you have to use Result.

See also
ResultMem
ResultPtr

Public Member Functions

 ResultMemT ()
 
MAXON_IMPLICIT ResultMemT (ERROR_FAILED)
 
MAXON_IMPLICIT ResultMemT (const T &value)
 
MAXON_IMPLICIT ResultMemT (T &&value)
 
MAXON_IMPLICIT ResultMemT (ERROR_OK)
 
MAXON_IMPLICIT ResultMemT (ResultOk< void >)
 
 ResultMemT (const ResultMemT &)=default
 
ResultMemToperator= (const ResultMemT &)=default
 
 ResultMemT (ResultMemT &&)=default
 
ResultMemToperator= (ResultMemT &&)=default
 
template<typename T2 , typename = typename std::enable_if<STD_IS_REPLACEMENT(constructible, T, T2*) && STD_IS_REPLACEMENT(pointer, T)>::type>
MAXON_IMPLICIT ResultMemT (const ResultMemT< T2 * > &result)
 
template<typename T2 , typename = typename std::enable_if<STD_IS_REPLACEMENT(constructible, T, T2*) && STD_IS_REPLACEMENT(pointer, T)>::type>
MAXON_IMPLICIT ResultMemT (ResultMemT< T2 * > &&result)
 
template<typename T2 , typename = typename std::enable_if<STD_IS_REPLACEMENT(constructible, T, T2) && STD_IS_REPLACEMENT(pointer, T) == STD_IS_REPLACEMENT(pointer, T2)>::type>
MAXON_IMPLICIT ResultMemT (const ResultMemT< T2 > &result)
 
template<typename T2 , typename = typename std::enable_if<STD_IS_REPLACEMENT(constructible, T, T2) && STD_IS_REPLACEMENT(pointer, T) == STD_IS_REPLACEMENT(pointer, T2)>::type>
MAXON_IMPLICIT ResultMemT (ResultMemT< T2 > &&result)
 
template<typename T2 >
MAXON_IMPLICIT ResultMemT (const ResultRef< T2 > &result)
 
Bool operator== (ERROR_OK ok) const
 
Bool operator== (ERROR_FAILED failed) const
 
const T & GetValue () const &
 
const T & UncheckedGetValue () const &
 
 MAXON_MEMBER_ACCESSORS (T, GetValue)
 
 MAXON_MEMBER_ACCESSORS (T, UncheckedGetValue)
 
GetPointer () const
 

Private Member Functions

Bool IsOK (const std::false_type *) const
 
Bool IsOK (const void *) const
 

Private Attributes

_value
 

Constructor & Destructor Documentation

◆ ResultMemT() [1/13]

◆ ResultMemT() [2/13]

◆ ResultMemT() [3/13]

MAXON_IMPLICIT ResultMemT ( const T &  value)

◆ ResultMemT() [4/13]

MAXON_IMPLICIT ResultMemT ( T &&  value)

◆ ResultMemT() [5/13]

◆ ResultMemT() [6/13]

◆ ResultMemT() [7/13]

ResultMemT ( const ResultMemT< T > &  )
default

◆ ResultMemT() [8/13]

ResultMemT ( ResultMemT< T > &&  )
default

◆ ResultMemT() [9/13]

MAXON_IMPLICIT ResultMemT ( const ResultMemT< T2 * > &  result)

◆ ResultMemT() [10/13]

MAXON_IMPLICIT ResultMemT ( ResultMemT< T2 * > &&  result)

◆ ResultMemT() [11/13]

MAXON_IMPLICIT ResultMemT ( const ResultMemT< T2 > &  result)

◆ ResultMemT() [12/13]

MAXON_IMPLICIT ResultMemT ( ResultMemT< T2 > &&  result)

◆ ResultMemT() [13/13]

MAXON_IMPLICIT ResultMemT ( const ResultRef< T2 > &  result)

Member Function Documentation

◆ operator=() [1/2]

ResultMemT& operator= ( const ResultMemT< T > &  )
default

◆ operator=() [2/2]

ResultMemT& operator= ( ResultMemT< T > &&  )
default

◆ operator==() [1/2]

Bool operator== ( ERROR_OK  ok) const

==(ERROR_OK)

==(ERROR_OK)

◆ operator==() [2/2]

Bool operator== ( ERROR_FAILED  failed) const

==(ERROR_FAILED)

==(ERROR_FAILED)

◆ GetValue()

const T& GetValue ( ) const &

Returns the result value. This function must not be called when there is no value because an out-of-memory error occurred.

Returns
Result value.

◆ UncheckedGetValue()

const T& UncheckedGetValue ( ) const &

Returns the result value, or a null value in case of an out-of-memory error.

Returns
Result value (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   
)

◆ GetPointer()

T GetPointer ( ) const

Returns the result value. This function is only supported if T is a pointer type.

Returns
Result value.

◆ IsOK() [1/2]

Bool IsOK ( const std::false_type *  ) const
private

◆ IsOK() [2/2]

Bool IsOK ( const void *  ) const
private

Member Data Documentation

◆ _value

T _value
private