engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
TValueOrError< ValueType, ErrorType > 模板类 参考

Type used to return either a value or an error. 更多...

#include <ValueOrError.h>

Public 成员函数

ErrorType & GetError () &
 Access the error. 更多...
 
ValueType & GetValue () &
 Access the value. 更多...
 
bool HasError () const
 Whether the error is set. 更多...
 
bool HasValue () const
 Whether the value is set. 更多...
 
bool IsValid () const
 Check whether a value is set. 更多...
 
ErrorType StealError ()
 Steal the error. 更多...
 
ValueType StealValue ()
 Steal the value. 更多...
 
ErrorType * TryGetError ()
 Access the error if it is set.
 
ValueType * TryGetValue ()
 Access the value if it is set.
 
template<typename ArgType >
 TValueOrError (TValueOrError_ErrorProxy< ArgType > &&Proxy)
 Construct the error from a proxy from MakeError.
 
template<typename ArgType >
 TValueOrError (TValueOrError_ValueProxy< ArgType > &&Proxy)
 Construct the value from a proxy from MakeValue.
 

详细描述

template<typename ValueType, typename ErrorType>
class TValueOrError< ValueType, ErrorType >

Type used to return either a value or an error.

These must have a value or an error when newly constructed, but it is possible to have neither because of the functions to steal the value or error. This is critical for callers to consider since it means that HasValue() and HasError() must be checked independently; a return value of false from one does not imply that the other will return true.

The MakeValue and MakeError functions may be used to construct these conveniently.

成员函数说明

◆ GetError()

template<typename ValueType , typename ErrorType >
ErrorType & TValueOrError< ValueType, ErrorType >::GetError ( ) &
inline

Access the error.

Asserts if this does not have an error.

◆ GetValue()

template<typename ValueType , typename ErrorType >
ValueType & TValueOrError< ValueType, ErrorType >::GetValue ( ) &
inline

Access the value.

Asserts if this does not have a value.

◆ HasError()

template<typename ValueType , typename ErrorType >
bool TValueOrError< ValueType, ErrorType >::HasError ( ) const
inline

Whether the error is set.

An error does imply no value. No error does not imply that a value is set.

◆ HasValue()

template<typename ValueType , typename ErrorType >
bool TValueOrError< ValueType, ErrorType >::HasValue ( ) const
inline

Whether the value is set.

A value does imply no error. No value does not imply that an error is set.

◆ IsValid()

template<typename ValueType , typename ErrorType >
bool TValueOrError< ValueType, ErrorType >::IsValid ( ) const
inline

Check whether a value is set.

Prefer HasValue and HasError to this. !IsValid() does not imply HasError().

◆ StealError()

template<typename ValueType , typename ErrorType >
ErrorType TValueOrError< ValueType, ErrorType >::StealError ( )
inline

Steal the error.

Asserts if this does not have an error. This causes the error to be unset.

◆ StealValue()

template<typename ValueType , typename ErrorType >
ValueType TValueOrError< ValueType, ErrorType >::StealValue ( )
inline

Steal the value.

Asserts if this does not have a value. This causes the value to be unset.


该类的文档由以下文件生成: