Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Templates
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Templates/ValueOrError.h |
Include | #include "Templates/ValueOrError.h" |
Syntax
template<typename ValueType, typename ErrorType>
class TValueOrError
Remarks
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.
Specializations
TValueOrError< ValueType, void >
TValueOrError< void, ErrorType >
TValueOrError< void, void >
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
TValueOrError
(
TValueOrError_ValueProxy< ArgTypes... >&& Proxy |
Construct the value from a proxy from MakeValue. | |
![]() |
TValueOrError
(
TValueOrError_ErrorProxy< ArgTypes... >&& Proxy |
Construct the error from a proxy from MakeError. |
Functions
Type | Name | Description | |
---|---|---|---|
![]() |
ErrorType | GetError () |
|
![]() ![]() |
const ErrorType & | GetError () |
|
![]() |
ErrorType & | GetError () |
Access the error. Asserts if this does not have an error. |
![]() |
ValueType & | GetValue () |
Access the value. Asserts if this does not have a value. |
![]() |
ValueType | GetValue () |
|
![]() ![]() |
const ValueType & | GetValue () |
|
![]() ![]() |
bool | HasError () |
Whether the error is set. |
![]() ![]() |
bool | HasValue () |
Whether the value is set. |
![]() ![]() |
bool | IsValid () |
Check whether a value is set. |
![]() |
ErrorType | StealError () |
Steal the error. Asserts if this does not have an error. This causes the error to be unset. |
![]() |
ValueType | StealValue () |
Steal the value. Asserts if this does not have a value. This causes the value to be unset. |
![]() |
ErrorType * | TryGetError () |
Access the error if it is set. |
![]() ![]() |
const ErrorType * | TryGetError () |
|
![]() |
ValueType * | TryGetValue () |
Access the value if it is set. |
![]() ![]() |
const ValueType * | TryGetValue () |