6#include "Misc/Optional.h"
7#include "Misc/TVariant.h"
8#include "Templates/Tuple.h"
9#include "Templates/UnrealTemplate.h"
11template <
typename... ArgTypes>
15 TTuple<ArgTypes&&...>
Args;
18template <
typename... ArgTypes>
22 TTuple<ArgTypes&&...>
Args;
25template <
typename... ArgTypes>
28 return TValueOrError_ValueProxy<ArgTypes...>(Forward<ArgTypes>(Args)...);
31template <
typename... ArgTypes>
34 return TValueOrError_ErrorProxy<ArgTypes...>(Forward<ArgTypes>(Args)...);
38
39
40
41
42
43
44
45
46
47template <
typename ValueType,
typename ErrorType>
53 template <
typename... ArgTypes>
63 template <
typename... ArgTypes, uint32... ArgIndices>
65 : Variant(TInPlaceType<ValueType>(), MoveTemp(Proxy.Args).
template Get<ArgIndices>()...)
69 template <
typename... ArgTypes, uint32... ArgIndices>
71 : Variant(TInPlaceType<FWrapErrorType>(), MoveTemp(Proxy.Args).
template Get<ArgIndices>()...)
77 template <
typename... ArgTypes>
79 : TValueOrError(MoveTemp(Proxy), TMakeIntegerSequence<uint32,
sizeof...(ArgTypes)>())
84 template <
typename... ArgTypes>
86 : TValueOrError(MoveTemp(Proxy), TMakeIntegerSequence<uint32,
sizeof...(ArgTypes)>())
91 inline bool IsValid()
const {
return Variant.
template IsType<ValueType>(); }
94 inline bool HasError()
const {
return Variant.
template IsType<FWrapErrorType>(); }
97 inline ErrorType&
GetError() & {
return Variant.
template Get<FWrapErrorType>().Error; }
98 inline const ErrorType&
GetError()
const & {
return Variant.
template Get<FWrapErrorType>().Error; }
99 inline ErrorType
GetError() && {
return MoveTemp(Variant.
template Get<FWrapErrorType>().Error); }
104 if (FWrapErrorType* Wrap = Variant.
template TryGet<FWrapErrorType>())
112 if (
const FWrapErrorType* Wrap = Variant.
template TryGet<FWrapErrorType>())
122 ErrorType Temp = MoveTemp(GetError());
123 Variant.
template Emplace<FEmptyType>();
128 inline bool HasValue()
const {
return Variant.
template IsType<ValueType>(); }
131 inline ValueType&
GetValue() & {
return Variant.
template Get<ValueType>(); }
132 inline const ValueType&
GetValue()
const & {
return Variant.
template Get<ValueType>(); }
133 inline ValueType
GetValue() && {
return MoveTemp(Variant.
template Get<ValueType>()); }
136 inline ValueType*
TryGetValue() {
return Variant.
template TryGet<ValueType>(); }
137 inline const ValueType*
TryGetValue()
const {
return Variant.
template TryGet<ValueType>(); }
142 ValueType Temp = MoveTemp(GetValue());
143 Variant.
template Emplace<FEmptyType>();
151template <
typename ValueType>
152class TValueOrError<ValueType,
void>
154 template <
typename... ArgTypes, uint32... ArgIndices>
156 : Value(InPlace, MoveTemp(Proxy.Args).
template Get<ArgIndices>()...)
162 template <
typename... ArgTypes>
164 : TValueOrError(MoveTemp(Proxy), TMakeIntegerSequence<uint32,
sizeof...(ArgTypes)>())
174 inline bool HasError()
const {
return !Value.IsSet(); }
177 inline bool HasValue()
const {
return Value.IsSet(); }
180 inline ValueType&
GetValue() & {
return Value.GetValue(); }
181 inline const ValueType&
GetValue()
const & {
return Value.GetValue(); }
182 inline ValueType
GetValue() && {
return MoveTemp(Value.GetValue()); }
186 inline const ValueType*
TryGetValue()
const {
return Value.GetPtrOrNull(); }
191 ValueType Temp = MoveTemp(GetValue());
200template <
typename ErrorType>
201class TValueOrError<
void, ErrorType>
203 template <
typename... ArgTypes, uint32... ArgIndices>
205 : Error(InPlace, MoveTemp(Proxy.Args).
template Get<ArgIndices>()...)
216 template <
typename... ArgTypes>
218 : TValueOrError(MoveTemp(Proxy), TMakeIntegerSequence<uint32,
sizeof...(ArgTypes)>())
223 inline bool HasValue()
const {
return !Error.IsSet(); }
226 inline bool HasError()
const {
return Error.IsSet(); }
229 inline ErrorType&
GetError() & {
return Error.GetValue(); }
230 inline const ErrorType&
GetError()
const & {
return Error.GetValue(); }
231 inline ErrorType
GetError() && {
return MoveTemp(Error.GetValue()); }
235 inline const ErrorType*
TryGetError()
const {
return Error.GetPtrOrNull(); }
240 ErrorType Temp = MoveTemp(GetError());
250class TValueOrError<
void,
void>
FORCEINLINE TValueOrError_ValueProxy< ArgTypes... > MakeValue(ArgTypes &&... Args)
FORCEINLINE TValueOrError_ErrorProxy< ArgTypes... > MakeError(ArgTypes &&... Args)
TValueOrError(TValueOrError_ErrorProxy<> &&Proxy)
ValueType * TryGetValue()
TValueOrError(TValueOrError_ValueProxy< ArgTypes... > &&Proxy, TIntegerSequence< uint32, ArgIndices... >)
const ValueType * TryGetValue() const
const ValueType & GetValue() const &
TValueOrError(TValueOrError_ValueProxy< ArgTypes... > &&Proxy)
TOptional< ValueType > Value
TValueOrError(TValueOrError_ErrorProxy< ArgTypes... > &&Proxy)
const ErrorType & GetError() const &
TValueOrError(TValueOrError_ValueProxy<> &&Proxy)
const ErrorType * TryGetError() const
TOptional< ErrorType > Error
ErrorType * TryGetError()
TValueOrError(TValueOrError_ErrorProxy< ArgTypes... > &&Proxy, TIntegerSequence< uint32, ArgIndices... >)
TValueOrError(TValueOrError_ValueProxy<> &&Proxy)
TValueOrError(TValueOrError_ErrorProxy<> &&Proxy)
const ValueType & GetValue() const &
ValueType * TryGetValue()
TValueOrError(TValueOrError_ErrorProxy< ArgTypes... > &&Proxy, TIntegerSequence< uint32, ArgIndices... >)
TValueOrError(TValueOrError_ValueProxy< ArgTypes... > &&Proxy)
const ValueType * TryGetValue() const
TValueOrError(TValueOrError_ValueProxy< ArgTypes... > &&Proxy, TIntegerSequence< uint32, ArgIndices... >)
ErrorType * TryGetError()
const ErrorType * TryGetError() const
TValueOrError(TValueOrError_ErrorProxy< ArgTypes... > &&Proxy)
TVariant< ValueType, FWrapErrorType, FEmptyType > Variant
const ErrorType & GetError() const &
FWrapErrorType(ArgTypes &&... Args)
TValueOrError_ErrorProxy(ArgTypes &&... InArgs)
TTuple< ArgTypes &&... > Args
TTuple< ArgTypes &&... > Args
TValueOrError_ValueProxy(ArgTypes &&... InArgs)