Navigation
API > API/Runtime > API/Runtime/Core
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.
| Name | TValueOrError |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Templates/ValueOrError.h |
| Include Path | #include "Templates/ValueOrError.h" |
Syntax
template<typename ValueType, typename ErrorType>
class TValueOrError
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TValueOrError
(
TValueOrError_ValueProxy< ArgTypes... >&& Proxy, |
Templates/ValueOrError.h | ||
TValueOrError
(
TValueOrError_ValueProxy< ArgTypes... >&& Proxy |
Construct the value from a proxy from MakeValue. | Templates/ValueOrError.h | |
TValueOrError
(
TValueOrError_ErrorProxy< ArgTypes... >&& Proxy |
Construct the error from a proxy from MakeError. | Templates/ValueOrError.h | |
TValueOrError
(
TValueOrError_ErrorProxy< ArgTypes... >&& Proxy, |
Templates/ValueOrError.h |
Class Specializations
| Name | Remarks |
|---|---|
| TValueOrError< ValueType, void > | |
| TValueOrError< void, ErrorType > | |
| TValueOrError< void, void > |
Structs
| Name | Remarks |
|---|---|
| FEmptyType | A unique empty type used in the unset state after stealing the value or error. |
| FWrapErrorType | Wrap the error type to allow ValueType and ErrorType to be the same type. |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Variant | TVariant< ValueType, FWrapErrorType, FEmptyType > | Templates/ValueOrError.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ErrorType && GetError () |
Templates/ValueOrError.h | ||
const ErrorType & GetError () |
Templates/ValueOrError.h | ||
ErrorType & GetError () |
Access the error. Asserts if this does not have an error. | Templates/ValueOrError.h | |
const ValueType & GetValue () |
Templates/ValueOrError.h | ||
ValueType && GetValue () |
Templates/ValueOrError.h | ||
ValueType & GetValue () |
Access the value. Asserts if this does not have a value. | Templates/ValueOrError.h | |
bool HasError () |
Whether the error is set. | Templates/ValueOrError.h | |
bool HasValue () |
Whether the value is set. | Templates/ValueOrError.h | |
bool IsValid () |
Check whether a value is set. | Templates/ValueOrError.h | |
ErrorType StealError() |
Steal the error. Asserts if this does not have an error. This causes the error to be unset. | Templates/ValueOrError.h | |
ValueType StealValue() |
Steal the value. Asserts if this does not have a value. This causes the value to be unset. | Templates/ValueOrError.h | |
ErrorType * TryGetError () |
Access the error if it is set. | Templates/ValueOrError.h | |
const ErrorType * TryGetError () |
Templates/ValueOrError.h | ||
ValueType * TryGetValue () |
Access the value if it is set. | Templates/ValueOrError.h | |
const ValueType * TryGetValue () |
Templates/ValueOrError.h |