41template <
typename T,
typename... Ts>
46 :
private std::conditional_t<!std::is_trivially_destructible_v<T> || (!std::is_trivially_destructible_v<Ts> || ...), UE::Core::Private::TDestructibleVariantStorage<T, Ts...> , UE::Core::Private::TVariantStorage<T, Ts...>>
49#if PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS
59 static_assert(
sizeof...(Ts) <= 255,
"TVariant cannot hold more than 256 types");
65 static_assert(std::is_constructible_v<T>,
"To default-initialize a TVariant, the first type in the parameter pack must be default constructible. Use FEmptyVariantState as the first type if none of the other types can be listed first.");
74 UE_REQUIRES(std::is_constructible_v<U, ArgTypes...>)
79 static_assert(
Index != (
SIZE_T)-1,
"The TVariant is not declared to hold the type being constructed");
88 TypeIndex =
Other.TypeIndex;
95 TypeIndex =
Other.TypeIndex;
121#if PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS
124 requires(!std::is_trivially_destructible_v<T> || (!std::is_trivially_destructible_v<Ts> || ...))
129 requires(std::is_trivially_destructible_v<T> && (std::is_trivially_destructible_v<Ts> && ...))
137 template <
typename U>
145 template <
typename U>
149 static_assert(
Index != (
SIZE_T)-1,
"The TVariant is not declared to hold the type passed to Get<>");
158 template <
typename U>
166 template <
typename U>
173 template <
typename U>
177 static_assert(
Index != (
SIZE_T)-1,
"The TVariant is not declared to hold the type passed to TryGet<>");
184 template <
typename U>
192 template <
typename U>
199 template <
typename U>
209 UE_REQUIRES(std::is_constructible_v<U, ArgTypes...>)
214 static_assert(
Index != (
SIZE_T)-1,
"The TVariant is not declared to hold the type passed to Emplace<>");
222 template <
typename U>
226 static_assert(
Index != (
SIZE_T)-1,
"The TVariant is not declared to hold the type passed to IndexOfType<>");
248 template <
typename U>
252 static_assert(
Index != (
SIZE_T)-1,
"The TVariant is not declared to store the specified type");
257#if PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS
261 using Super::TypeIndex;
271decltype(
auto)
Visit(Func&& Callable, Variants&&... Args)
291template <
typename... Ts>
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
typename TIdentity< T >::Type TIdentity_T
Definition Identity.h:24
typename UE4IntegerSequence_Private::TMakeIntegerSequenceImpl< T, N >::Type TMakeIntegerSequence
Definition IntegerSequence.h:31
#define UE_REQUIRES(...)
Definition Requires.h:86
FArchive & operator<<(typename UE::Core::Private::TAlwaysFArchive< TVariant< Ts... > >::Type &Ar, TVariant< Ts... > &Variant)
Definition TVariant.h:292
decltype(auto) Visit(Func &&Callable, Variants &&... Args)
Definition TVariant.h:271
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
if(Failed) console_printf("Failed.\n")
Definition Archive.h:1208
static constexpr SIZE_T IndexOfType()
Definition TVariant.h:223
void Emplace(ArgTypes &&... Args)
Definition TVariant.h:211
const U * TryGet() const UE_LIFETIMEBOUND
Definition TVariant.h:185
const U & Get(const TIdentity_T< U > &DefaultValue UE_LIFETIMEBOUND) const UE_LIFETIMEBOUND
Definition TVariant.h:167
TVariant(const TVariant &Other)
Definition TVariant.h:86
U & Get() UE_LIFETIMEBOUND
Definition TVariant.h:146
TVariant()
Definition TVariant.h:63
TVariant(TVariant &&Other)
Definition TVariant.h:93
void Set(typename TIdentity< U >::Type &&Value)
Definition TVariant.h:193
U * TryGet() UE_LIFETIMEBOUND
Definition TVariant.h:174
void Set(const typename TIdentity< U >::Type &Value)
Definition TVariant.h:200
const U & Get() const UE_LIFETIMEBOUND
Definition TVariant.h:159
TVariant(TInPlaceType< U > &&, ArgTypes &&... Args)
Definition TVariant.h:76
TVariant & operator=(const TVariant &Other)
Definition TVariant.h:100
bool IsType() const
Definition TVariant.h:138
TVariant(UE::Core::Private::TUninitializedType< U > &&)
Definition TVariant.h:249
SIZE_T GetIndex() const
Definition TVariant.h:231
TVariant & operator=(TVariant &&Other)
Definition TVariant.h:111
implementation
Definition PlayInEditorLoadingScope.h:8
SIZE_T EncodeIndices(const T &Variant)
Definition TVariantMeta.h:310
decltype(auto) VisitImpl(SIZE_T EncodedIndex, Func &&Callable, TIntegerSequence< SIZE_T, EncodedIndices... > &&, TIntegerSequence< SIZE_T, VariantIndices... > &&VariantIndicesSeq, Variants &&... Args)
Definition TVariantMeta.h:377
UE_FORCEINLINE_HINT TVariantStorage< Ts... > & CastToStorage(TVariant< Ts... > &Variant)
Definition TVariantMeta.h:335
U16 Index
Definition radfft.cpp:71
friend FArchive & operator<<(FArchive &Ar, FEmptyVariantState &)
Definition TVariant.h:31
T Type
Definition Identity.h:19
Definition TVariantMeta.h:63
Definition TVariantMeta.h:98
static void Construct(SIZE_T TypeIndex, void *Storage, const void *Value)
Definition TVariantMeta.h:233
Definition TVariantMeta.h:389
static void Destruct(SIZE_T TypeIndex, void *Value)
Definition TVariantMeta.h:209
static bool IsSame(SIZE_T TypeIndex)
Definition TVariantMeta.h:300
static void Construct(SIZE_T TypeIndex, void *Target, void *Source)
Definition TVariantMeta.h:258
Definition TVariantMeta.h:190
Definition TVariantMeta.h:69
static void Load(SIZE_T TypeIndex, FArchive &Ar, VariantType &OutVariant)
Definition TVariantMeta.h:287
Definition TVariantMeta.h:105