UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TVariant.h File Reference
#include "Templates/Requires.h"
#include "TVariantMeta.h"
#include <type_traits>

Go to the source code of this file.

Classes

struct  TInPlaceType< T >
 
struct  UE::Core::Private::TUninitializedType< T >
 
struct  FEmptyVariantState
 
class  TVariant< T, Ts >
 

Namespaces

namespace  UE
 
namespace  UE::Core
 
namespace  UE::Core::Private
 implementation
 

Functions

template<typename Func , typename... Variants>
decltype(autoVisit (Func &&Callable, Variants &&... Args)
 
template<typename... Ts>
FArchiveoperator<< (typename UE::Core::Private::TAlwaysFArchive< TVariant< Ts... > >::Type &Ar, TVariant< Ts... > &Variant)
 

Function Documentation

◆ operator<<()

template<typename... Ts>
FArchive & operator<< ( typename UE::Core::Private::TAlwaysFArchive< TVariant< Ts... > >::Type &  Ar,
TVariant< Ts... > &  Variant 
)
inline

Serialization function for TVariants.

In order for a TVariant to be serializable, each type in its template parameter pack must:

  1. Have a default constructor. This is required because when reading the type from an archive, it must be default constructed before being loaded.
  2. Implement the FArchive& operator<<(FArchive&, T&) function. This is required to serialize the actual type that's stored in TVariant.

◆ Visit()

template<typename Func , typename... Variants>
decltype(auto) Visit ( Func &&  Callable,
Variants &&...  Args 
)

Apply a visitor function to the list of variants