ResultBase< T > Class Template Reference

#include <resultbase.h>

详细描述

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

Base class for Result .

Public Types

using  ValueType = T

公共成员函数

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

静态公共属性

static const 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

构造函数 & 析构函数文档编制

◆  ResultBase() [1/3]

ResultBase ( )

◆  ResultBase() [2/3]

ResultBase ( CopyType   value )
explicit

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

参数
[in] value Result 值。

◆  ResultBase() [3/3]

ResultBase ( MoveType   value )
explicit

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

参数
[in] value Result 值。

成员函数文档编制

◆  GetValue()

const MAXON_ATTRIBUTE_FORCE_INLINE T& GetValue ( ) const &

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

返回
Result 值。

◆  UncheckedGetValue()

const MAXON_ATTRIBUTE_FORCE_INLINE T& UncheckedGetValue ( ) const &

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

返回
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]

const MAXON_ATTRIBUTE_FORCE_INLINE 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.

参数
[out] error This parameter receives the error (or a nullptr if there is no error).
返回
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.

参数
[out] error This parameter receives the error (or a nullptr if there is no error).
返回
Result value (or a null value in case of an error).

◆  GetValueAndError() [3/4]

const MAXON_ATTRIBUTE_FORCE_INLINE 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.

参数
[out] error This parameter receives the error (or a nullptr if there is no error).
返回
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.

参数
[out] error This parameter receives the error (or a nullptr if there is no error).
返回
Result value (or a null value in case of an error).

◆  GetErrorStorage() [1/2]

const MAXON_ATTRIBUTE_FORCE_INLINE ThreadReferencedError & GetErrorStorage ( ) const

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

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

◆  GetErrorStorage() [2/2]

MAXON_ATTRIBUTE_FORCE_INLINE ThreadReferencedError & GetErrorStorage ( )

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

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

Member Data Documentation

◆  HAS_ERROR

const Bool HAS_ERROR static

◆  _error

ThreadReferencedError _error
protected

◆  _value

T _value protected