Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TVariant< T, Ts > Class Template Referencefinal

#include <TVariant.h>

+ Inheritance diagram for TVariant< T, Ts >:
+ Collaboration diagram for TVariant< T, Ts >:

Public Member Functions

 TVariant ()
 
template<typename U , typename... TArgs>
 TVariant (TInPlaceType< U > &&, TArgs &&... Args)
 
 TVariant (const TVariant &Other)
 
 TVariant (TVariant &&Other)
 
TVariantoperator= (const TVariant &Other)
 
TVariantoperator= (TVariant &&Other)
 
 ~TVariant ()
 
template<typename U >
bool IsType () const
 
template<typename U >
UGet ()
 
template<typename U >
const UGet () const
 
template<typename U >
UTryGet ()
 
template<typename U >
const UTryGet () const
 
template<typename U >
void Set (typename TIdentity< U >::Type &&Value)
 
template<typename U >
void Set (const typename TIdentity< U >::Type &Value)
 
template<typename U , typename... TArgs>
void Emplace (TArgs &&... Args)
 
SIZE_T GetIndex () const
 

Static Public Member Functions

template<typename U >
static constexpr SIZE_T IndexOfType ()
 

Private Attributes

uint8 TypeIndex
 
- Private Attributes inherited from UE::Core::Private::TVariantStorage< T, Ts... >
TAlignedBytes< SizeofValue, AlignofValue > Storage
 

Additional Inherited Members

- Private Member Functions inherited from UE::Core::Private::TVariantStorage< T, Ts... >
autoGetValueAsIndexedType () &
 
auto && GetValueAsIndexedType () &&
 
const autoGetValueAsIndexedType () const &
 
- Static Private Member Functions inherited from UE::Core::Private::TVariantStorage< T, Ts... >
static constexpr SIZE_T MaxOf (const SIZE_T Sizes[])
 
static constexpr SIZE_T MaxSizeof ()
 
static constexpr SIZE_T MaxAlignof ()
 
- Static Private Attributes inherited from UE::Core::Private::TVariantStorage< T, Ts... >
static constexpr SIZE_T SizeofValue
 
static constexpr SIZE_T AlignofValue
 

Detailed Description

template<typename T, typename... Ts>
class TVariant< T, Ts >

A type-safe union based loosely on std::variant. This flavor of variant requires that all the types in the declaring template parameter pack be unique. Attempting to use the value of a Get() when the underlying type is different leads to undefined behavior.

Definition at line 33 of file TVariant.h.

Constructor & Destructor Documentation

◆ TVariant() [1/4]

template<typename T , typename... Ts>
TVariant< T, Ts >::TVariant ( )
inline

Default initialize the TVariant to the first type in the parameter pack

Definition at line 43 of file TVariant.h.

◆ TVariant() [2/4]

template<typename T , typename... Ts>
template<typename U , typename... TArgs>
TVariant< T, Ts >::TVariant ( TInPlaceType< U > && ,
TArgs &&... Args )
inlineexplicit

Perform in-place construction of a type into the variant

Definition at line 52 of file TVariant.h.

◆ TVariant() [3/4]

template<typename T , typename... Ts>
TVariant< T, Ts >::TVariant ( const TVariant< T, Ts > & Other)
inline

Copy construct the variant from another variant of the same type

Definition at line 62 of file TVariant.h.

◆ TVariant() [4/4]

template<typename T , typename... Ts>
TVariant< T, Ts >::TVariant ( TVariant< T, Ts > && Other)
inline

Move construct the variant from another variant of the same type

Definition at line 69 of file TVariant.h.

◆ ~TVariant()

template<typename T , typename... Ts>
TVariant< T, Ts >::~TVariant ( )
inline

Destruct the underlying type (if appropriate)

Definition at line 98 of file TVariant.h.

Member Function Documentation

◆ Emplace()

template<typename T , typename... Ts>
template<typename U , typename... TArgs>
void TVariant< T, Ts >::Emplace ( TArgs &&... Args)
inline

Set a specifically-typed value into the variant using in-place construction

Definition at line 167 of file TVariant.h.

◆ Get() [1/2]

template<typename T , typename... Ts>
template<typename U >
U & TVariant< T, Ts >::Get ( )
inline

Get a reference to the held value. Bad things can happen if this is called on a variant that does not hold the type asked for

Definition at line 113 of file TVariant.h.

◆ Get() [2/2]

template<typename T , typename... Ts>
template<typename U >
const U & TVariant< T, Ts >::Get ( ) const
inline

Get a reference to the held value. Bad things can happen if this is called on a variant that does not hold the type asked for

Definition at line 126 of file TVariant.h.

◆ GetIndex()

template<typename T , typename... Ts>
SIZE_T TVariant< T, Ts >::GetIndex ( ) const
inline

Returns the currently held type's index into the template parameter pack

Definition at line 187 of file TVariant.h.

◆ IndexOfType()

template<typename T , typename... Ts>
template<typename U >
static constexpr SIZE_T TVariant< T, Ts >::IndexOfType ( )
inlinestaticconstexpr

Lookup the index of a type in the template parameter pack at compile time.

Definition at line 179 of file TVariant.h.

◆ IsType()

template<typename T , typename... Ts>
template<typename U >
bool TVariant< T, Ts >::IsType ( ) const
inline

Determine if the variant holds the specific type

Definition at line 105 of file TVariant.h.

◆ operator=() [1/2]

template<typename T , typename... Ts>
TVariant & TVariant< T, Ts >::operator= ( const TVariant< T, Ts > & Other)
inline

Copy assign a variant from another variant of the same type

Definition at line 76 of file TVariant.h.

◆ operator=() [2/2]

template<typename T , typename... Ts>
TVariant & TVariant< T, Ts >::operator= ( TVariant< T, Ts > && Other)
inline

Move assign a variant from another variant of the same type

Definition at line 87 of file TVariant.h.

◆ Set() [1/2]

template<typename T , typename... Ts>
template<typename U >
void TVariant< T, Ts >::Set ( const typename TIdentity< U >::Type & Value)
inline

Set a specifically-typed value into the variant

Definition at line 160 of file TVariant.h.

◆ Set() [2/2]

template<typename T , typename... Ts>
template<typename U >
void TVariant< T, Ts >::Set ( typename TIdentity< U >::Type && Value)
inline

Set a specifically-typed value into the variant

Definition at line 153 of file TVariant.h.

◆ TryGet() [1/2]

template<typename T , typename... Ts>
template<typename U >
U * TVariant< T, Ts >::TryGet ( )
inline

Get a pointer to the held value if the held type is the same as the one specified

Definition at line 134 of file TVariant.h.

◆ TryGet() [2/2]

template<typename T , typename... Ts>
template<typename U >
const U * TVariant< T, Ts >::TryGet ( ) const
inline

Get a pointer to the held value if the held type is the same as the one specified

Definition at line 145 of file TVariant.h.

Member Data Documentation

◆ TypeIndex

template<typename T , typename... Ts>
uint8 TVariant< T, Ts >::TypeIndex
private

Index into the template parameter pack for the type held.

Definition at line 194 of file TVariant.h.


The documentation for this class was generated from the following file: