UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UnrealTemplate.h File Reference

Go to the source code of this file.

Classes

class  FNoncopyable
 
struct  TGuardValue< RefType, AssignedType >
 
struct  TOptionalGuardValue< RefType, AssignedType >
 
struct  TGuardValue_Bitfield_Cleanup< FuncType >
 
struct  TScopeCounter< Type >
 
struct  TKeyValuePair< KeyType, ValueType >
 
struct  TRemovePointer< T >
 
struct  TRemovePointer< T * >
 
struct  TRValueToLValueReference< T >
 
struct  TRValueToLValueReference< T && >
 
struct  TForceInitAtBoot< T >
 
struct  FNoopStruct
 

Namespaces

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

Macros

#define UE_ARRAY_COUNT(array)   (sizeof(UEArrayCountHelper(array)) - 1)
 
#define STRUCT_OFFSET(struc, member)   offsetof(struc, member)
 
#define VTABLE_OFFSET(Class, MultipleInheritenceParent)   ( ((PTRINT) static_cast<MultipleInheritenceParent*>((Class*)1)) - 1)
 
#define UE_FORCE_CONSTEVAL(expr)   UE::Core::Private::TForceConstEval_V<std::decay_t<decltype(expr)>, (expr)>
 
#define FGuardValue_Bitfield(ReferenceValue, NewValue)
 
#define TEMPLATE_PARAMETERS2(X, Y)   X,Y
 

Functions

template<typename T >
void Move (T &A, typename TMoveSupportTraits< T >::Copy B)
 
template<typename T >
void Move (T &A, typename TMoveSupportTraits< T >::Move B)
 
template<typename T >
constexpr auto UE::Core::Private::GetDataImpl (T &&Container) -> decltype(Container.GetData())
 
template<typename T >
constexpr auto UE::Core::Private::GetNumImpl (const T &Container) -> decltype(Container.Num())
 
template<typename T >
constexpr auto GetData (T &&Container) -> decltype(UE::Core::Private::GetDataImpl((T &&) Container))
 
template<typename T >
constexpr const T * GetData (std::initializer_list< T > List)
 
template<typename T >
constexpr auto GetNum (const T &Container) -> decltype(UE::Core::Private::GetNumImpl(Container))
 
template<typename T >
constexpr int32 GetNum (std::initializer_list< T > List)
 
template<typename T >
constexpr UE_FORCEINLINE_HINT const T & AsConst (T &Ref)
 
template<typename T >
void AsConst (const T &&Ref)=delete
 
template<typename T , SIZE_T N>
constexpr UE_FORCEINLINE_HINT const T(& AsConst (T(&Array)[N]))[N]
 
template<typename OutType , typename InType >
constexpr bool IntFitsIn (InType In)
 
template<typename OutType , typename InType >
OutType IntCastChecked (InType In)
 
template<typename OutType , typename InType >
constexpr bool FloatFitsIn (InType In, InType Precision)
 
template<typename OutType , typename InType >
OutType FloatCastChecked (InType In, InType Precision)
 
template<typename T , uint32 N>
char(& UEArrayCountHelper (const T(&)[N]))[N+1]
 
template<class ForwardIt >
ForwardIt MinElement (ForwardIt First, ForwardIt Last)
 
template<class ForwardIt , class PredicateType >
ForwardIt MinElement (ForwardIt First, ForwardIt Last, PredicateType Predicate)
 
template<class ForwardIt >
ForwardIt MaxElement (ForwardIt First, ForwardIt Last)
 
template<class ForwardIt , class PredicateType >
ForwardIt MaxElement (ForwardIt First, ForwardIt Last, PredicateType Predicate)
 
template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp (T &&Obj) noexcept
 
template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTempIfPossible (T &&Obj) noexcept
 
template<typename T >
UE_REWRITECopyTemp (T &Val)
 
template<typename T >
UE_REWRITECopyTemp (const T &Val)
 
template<typename T >
UE_REWRITE constexpr std::decay_t< T > CopyTempIfNecessary (T &&Val)
 
template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr T && Forward (std::remove_reference_t< T > &Obj) noexcept
 
template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr T && Forward (std::remove_reference_t< T > &&Obj) noexcept
 
template<typename T >
constexpr void Swap (T &A, T &B)
 
template<typename T >
UE_REWRITE constexpr void Exchange (T &A, T &B)
 
template<typename T , typename ArgType >
UE_REWRITEStaticCast (ArgType &&Arg)
 
template<typename T >
ReverseBits (T Bits)
 
template<typename T >
UE_FORCEINLINE_HINTBitMask (uint32 Count)
 
template<>
uint64 BitMask< uint64 > (uint32 Count)
 
template<>
uint32 BitMask< uint32 > (uint32 Count)
 
template<>
uint16 BitMask< uint16 > (uint32 Count)
 
template<>
uint8 BitMask< uint8 > (uint32 Count)
 
template<typename T >
T && DeclVal ()
 
template<typename T >
UE_REWRITE constexprImplicitConv (typename TIdentity< T >::Type Obj)
 
template<typename T , typename Base >
UE_INTRINSIC_CAST UE_REWRITE decltype(autoForwardAsBase (std::remove_reference_t< T > &Obj)
 
template<typename T , typename Base >
UE_INTRINSIC_CAST UE_REWRITE decltype(autoForwardAsBase (std::remove_reference_t< T > &&Obj)
 

Variables

template<typename T , T Val>
constexprUE::Core::Private::TForceConstEval_V = Val
 

Macro Definition Documentation

◆ FGuardValue_Bitfield

#define FGuardValue_Bitfield (   ReferenceValue,
  NewValue 
)
Value:
const bool PREPROCESSOR_JOIN(TempBitfield, __LINE__) = ReferenceValue; \
ReferenceValue = NewValue; \
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PREPROCESSOR_JOIN(TokenA, TokenB)
Definition PreprocessorHelpers.h:104
Definition AndroidPlatformMisc.h:14
Definition UnrealTemplate.h:411

Macro variant on TGuardValue<bool> that can deal with bitfields which cannot be passed by reference in to TGuardValue

◆ STRUCT_OFFSET

#define STRUCT_OFFSET (   struc,
  member 
)    offsetof(struc, member)

◆ TEMPLATE_PARAMETERS2

#define TEMPLATE_PARAMETERS2 (   X,
  Y 
)    X,Y

◆ UE_ARRAY_COUNT

#define UE_ARRAY_COUNT (   array)    (sizeof(UEArrayCountHelper(array)) - 1)

◆ UE_FORCE_CONSTEVAL

#define UE_FORCE_CONSTEVAL (   expr)    UE::Core::Private::TForceConstEval_V<std::decay_t<decltype(expr)>, (expr)>

◆ VTABLE_OFFSET

#define VTABLE_OFFSET (   Class,
  MultipleInheritenceParent 
)    ( ((PTRINT) static_cast<MultipleInheritenceParent*>((Class*)1)) - 1)

Function Documentation

◆ AsConst() [1/3]

template<typename T >
void AsConst ( const T &&  Ref)
delete

Disallowed for rvalue references because it cannot extend their lifetime.

◆ AsConst() [2/3]

template<typename T >
constexpr UE_FORCEINLINE_HINT const T & AsConst ( T &  Ref)
constexpr

Returns a non-const reference type as const.

◆ AsConst() [3/3]

template<typename T , SIZE_T N>
constexpr UE_FORCEINLINE_HINT const T(& AsConst ( T(&)  Array[N]) )[N]
constexpr

Returns a non-const reference type as const. This overload is only required until the pointer overloads are removed.

◆ BitMask()

template<typename T >
UE_FORCEINLINE_HINT T BitMask ( uint32  Count)

Generates a bitmask with a given number of bits set.

◆ BitMask< uint16 >()

template<>
uint16 BitMask< uint16 > ( uint32  Count)
inline

◆ BitMask< uint32 >()

template<>
uint32 BitMask< uint32 > ( uint32  Count)
inline

◆ BitMask< uint64 >()

template<>
uint64 BitMask< uint64 > ( uint32  Count)
inline

◆ BitMask< uint8 >()

template<>
uint8 BitMask< uint8 > ( uint32  Count)
inline

◆ CopyTemp() [1/2]

template<typename T >
UE_REWRITE T CopyTemp ( const T &  Val)

◆ CopyTemp() [2/2]

template<typename T >
UE_REWRITE T CopyTemp ( T &  Val)

CopyTemp will enforce the creation of a prvalue which can bind to rvalue reference parameters. Unlike MoveTemp, a source lvalue will never be modified. (i.e. a copy will always be made) There is no std:: equivalent, though there is the exposition function std::decay-copy: https://eel.is/c++draft/expos.only.func CopyTemp(<rvalue>) is regarded as an error and will not compile, similarly to how MoveTemp(<rvalue>) does not compile, and CopyTempIfNecessary should be used instead when the nature of the argument is not known in advance.

◆ CopyTempIfNecessary()

template<typename T >
UE_REWRITE constexpr std::decay_t< T > CopyTempIfNecessary ( T &&  Val)
constexpr

CopyTempIfNecessary will enforce the creation of a prvalue. This is UE's equivalent of the exposition std::decay-copy: https://eel.is/c++draft/expos.only.func It doesn't static assert like CopyTemp, because it is useful in templates or macros where it's not obvious what the argument is, but you want to create a PR value without stopping compilation.

◆ DeclVal()

template<typename T >
T && DeclVal ( )

Equivalent to std::declval.

Note that this function is unimplemented, and is only intended to be used in unevaluated contexts, like sizeof and trait expressions.

◆ Exchange()

template<typename T >
UE_REWRITE constexpr void Exchange ( T &  A,
T &  B 
)
constexpr

◆ FloatCastChecked()

OutType FloatCastChecked ( InType  In,
InType  Precision 
)

◆ FloatFitsIn()

constexpr bool FloatFitsIn ( InType  In,
InType  Precision 
)
constexpr

Test if value can make a static_cast roundtrip via OutType whilst maintaining precision

◆ Forward() [1/2]

template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr T && Forward ( std::remove_reference_t< T > &&  Obj)
constexprnoexcept

◆ Forward() [2/2]

template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr T && Forward ( std::remove_reference_t< T > &  Obj)
constexprnoexcept

Forward will cast a reference to an rvalue reference. This is UE's equivalent of std::forward.

◆ ForwardAsBase() [1/2]

template<typename T , typename Base >
UE_INTRINSIC_CAST UE_REWRITE decltype(auto) ForwardAsBase ( std::remove_reference_t< T > &&  Obj)

◆ ForwardAsBase() [2/2]

template<typename T , typename Base >
UE_INTRINSIC_CAST UE_REWRITE decltype(auto) ForwardAsBase ( std::remove_reference_t< T > &  Obj)

ForwardAsBase will cast a reference to an rvalue reference of a base type. This allows the perfect forwarding of a reference as a base class.

◆ GetData() [1/2]

template<typename T >
constexpr const T * GetData ( std::initializer_list< T >  List)
constexpr

◆ GetData() [2/2]

template<typename T >
constexpr auto GetData ( T &&  Container) -> decltype(UE::Core::Private::GetDataImpl((T&&)Container))
constexpr

Generically gets the data pointer of a contiguous container

◆ GetNum() [1/2]

template<typename T >
constexpr auto GetNum ( const T &  Container) -> decltype(UE::Core::Private::GetNumImpl(Container))
constexpr

Generically gets the number of items in a contiguous container

◆ GetNum() [2/2]

template<typename T >
constexpr int32 GetNum ( std::initializer_list< T >  List)
constexpr

Gets the number of items in an initializer list.

The return type is int32 for compatibility with other code in the engine. Realistically, an initializer list should not exceed the limits of int32.

◆ ImplicitConv()

template<typename T >
UE_REWRITE constexpr T ImplicitConv ( typename TIdentity< T >::Type  Obj)
constexpr

Uses implicit conversion to create an instance of a specific type. Useful to make things clearer or circumvent unintended type deduction in templates. Safer than C casts and static_casts, e.g. does not allow down-casts

Parameters
ObjThe object (usually pointer or reference) to convert.
Returns
The object converted to the specified type.

◆ IntCastChecked()

OutType IntCastChecked ( InType  In)

Cast and check that value fits in OutType

◆ IntFitsIn()

constexpr bool IntFitsIn ( InType  In)
constexpr

Test if value can make a lossless static_cast roundtrip via OutType without a sign change

◆ MaxElement() [1/2]

template<class ForwardIt >
ForwardIt MaxElement ( ForwardIt  First,
ForwardIt  Last 
)
inline

works just like std::max_element.

◆ MaxElement() [2/2]

template<class ForwardIt , class PredicateType >
ForwardIt MaxElement ( ForwardIt  First,
ForwardIt  Last,
PredicateType  Predicate 
)
inline

works just like std::max_element.

◆ MinElement() [1/2]

template<class ForwardIt >
ForwardIt MinElement ( ForwardIt  First,
ForwardIt  Last 
)
inline

works just like std::min_element.

◆ MinElement() [2/2]

template<class ForwardIt , class PredicateType >
ForwardIt MinElement ( ForwardIt  First,
ForwardIt  Last,
PredicateType  Predicate 
)
inline

works just like std::min_element.

◆ Move() [1/2]

template<typename T >
void Move ( T &  A,
typename TMoveSupportTraits< T >::Copy  B 
)
inline

This is used to provide type specific behavior for a copy which cannot change the value of B.

◆ Move() [2/2]

template<typename T >
void Move ( T &  A,
typename TMoveSupportTraits< T >::Move  B 
)
inline

This is used to provide type specific behavior for a move which may change the value of B.

◆ MoveTemp()

template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp ( T &&  Obj)
constexprnoexcept

MoveTemp will cast a reference to an rvalue reference. This is UE's equivalent of std::move except that it will not compile when passed an rvalue or const object, because we would prefer to be informed when MoveTemp will have no effect.

◆ MoveTempIfPossible()

template<typename T >
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTempIfPossible ( T &&  Obj)
constexprnoexcept

MoveTempIfPossible will cast a reference to an rvalue reference. This is UE's equivalent of std::move. It doesn't static assert like MoveTemp, because it is useful in templates or macros where it's not obvious what the argument is, but you want to take advantage of move semantics where you can but not stop compilation.

◆ ReverseBits()

template<typename T >
T ReverseBits ( Bits)
inline

Reverses the order of the bits of a value. This is a constrained template to ensure that no undesirable conversions occur. Overloads for other types can be added in the same way.

Parameters
Bits- The value to bit-swap.
Returns
The bit-swapped value.

◆ StaticCast()

template<typename T , typename ArgType >
UE_REWRITE T StaticCast ( ArgType &&  Arg)

This exists to avoid a Visual Studio bug where using a cast to forward an rvalue reference array argument to a pointer parameter will cause bad code generation. Wrapping the cast in a function causes the correct code to be generated.

◆ Swap()

template<typename T >
constexpr void Swap ( T &  A,
T &  B 
)
inlineconstexpr

Swap two values. Assumes the types are trivially relocatable.

◆ UEArrayCountHelper()

template<typename T , uint32 N>
char(& UEArrayCountHelper ( const   T(&)[N]) )[N+1]