Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
UnrealTemplate.h File Reference
+ Include dependency graph for UnrealTemplate.h:

Go to the source code of this file.

Classes

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

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 FGuardValue_Bitfield(ReferenceValue, NewValue)
 
#define TEMPLATE_PARAMETERS2(X, Y)   X,Y
 

Functions

template<typename ReferencedType >
FORCEINLINE ReferencedTypeIfAThenAElseB (ReferencedType *A, ReferencedType *B)
 
template<typename PredicateType , typename ReferencedType >
FORCEINLINE ReferencedTypeIfPThenAElseB (PredicateType Predicate, ReferencedType *A, ReferencedType *B)
 
bool XOR (bool A, bool B)
 
template<typename T >
FORCEINLINE void Move (T &A, typename TMoveSupportTraits< T >::Copy B)
 
template<typename T >
FORCEINLINE void Move (T &A, typename TMoveSupportTraits< T >::Move B)
 
template<typename T , typename = typename TEnableIf<TIsContiguousContainer<T>::Value>::Type>
constexpr auto GetData (T &&Container) -> decltype(Container.GetData())
 
template<typename T , SIZE_T N>
constexpr TGetData (T(&Container)[N])
 
template<typename T , SIZE_T N>
constexpr TGetData (T(&&Container)[N])
 
template<typename T , SIZE_T N>
constexpr const TGetData (const T(&Container)[N])
 
template<typename T , SIZE_T N>
constexpr const TGetData (const T(&&Container)[N])
 
template<typename T >
constexpr const TGetData (std::initializer_list< T > List)
 
template<typename T , typename = typename TEnableIf<TIsContiguousContainer<T>::Value>::Type>
constexpr auto GetNum (T &&Container) -> decltype(Container.Num())
 
template<typename T , SIZE_T N>
constexpr SIZE_T GetNum (T(&Container)[N])
 
template<typename T , SIZE_T N>
constexpr SIZE_T GetNum (T(&&Container)[N])
 
template<typename T , SIZE_T N>
constexpr SIZE_T GetNum (const T(&Container)[N])
 
template<typename T , SIZE_T N>
constexpr SIZE_T GetNum (const T(&&Container)[N])
 
template<typename T >
constexpr int32 GetNum (std::initializer_list< T > List)
 
template<typename T >
constexpr FORCEINLINE const TAsConst (T *const &Ptr)
 
template<typename T >
constexpr FORCEINLINE const TAsConst (T *const &&Ptr)
 
template<typename T >
constexpr FORCEINLINE const TAsConst (T &Ref)
 
template<typename T >
void AsConst (const T &&Ref)=delete
 
template<typename T , SIZE_T N>
constexpr FORCEINLINE 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 >
FORCEINLINE TRemoveReference< T >::Type && MoveTemp (T &&Obj)
 
template<typename T >
FORCEINLINE TRemoveReference< T >::Type && MoveTempIfPossible (T &&Obj)
 
template<typename T >
FORCEINLINE T CopyTemp (T &Val)
 
template<typename T >
FORCEINLINE T CopyTemp (const T &Val)
 
template<typename T >
FORCEINLINE T && CopyTemp (T &&Val)
 
template<typename T >
FORCEINLINE std::decay_t< TCopyTempIfNecessary (T &&Val)
 
template<typename T >
FORCEINLINE T && Forward (typename TRemoveReference< T >::Type &Obj)
 
template<typename T >
FORCEINLINE T && Forward (typename TRemoveReference< T >::Type &&Obj)
 
template<typename T >
TEnableIf< TUseBitwiseSwap< T >::Value >::Type Swap (T &A, T &B)
 
template<typename T >
TEnableIf<!TUseBitwiseSwap< T >::Value >::Type Swap (T &A, T &B)
 
template<typename T >
void Exchange (T &A, T &B)
 
template<typename T , typename ArgType >
FORCEINLINE T StaticCast (ArgType &&Arg)
 
template<typename T >
FORCEINLINE TEnableIf< std::is_same_v< T, uint32 >, T >::Type ReverseBits (T Bits)
 
template<typename T >
FORCEINLINE T BitMask (uint32 Count)
 
template<>
FORCEINLINE uint64 BitMask< uint64 > (uint32 Count)
 
template<>
FORCEINLINE uint32 BitMask< uint32 > (uint32 Count)
 
template<>
FORCEINLINE uint16 BitMask< uint16 > (uint32 Count)
 
template<>
FORCEINLINE uint8 BitMask< uint8 > (uint32 Count)
 
template<typename T >
T && DeclVal ()
 
template<typename T >
FORCEINLINE T ImplicitConv (typename TIdentity< T >::Type Obj)
 
template<typename T , typename Base , decltype(ImplicitConv< const volatile Base * >((typename TRemoveReference< T >::Type *) nullptr)) * = nullptr>
FORCEINLINE decltype(autoForwardAsBase (typename TRemoveReference< T >::Type &Obj)
 
template<typename T , typename Base , decltype(ImplicitConv< const volatile Base * >((typename TRemoveReference< T >::Type *) nullptr)) * = nullptr>
FORCEINLINE decltype(autoForwardAsBase (typename TRemoveReference< T >::Type &&Obj)
 

Macro Definition Documentation

◆ FGuardValue_Bitfield

#define FGuardValue_Bitfield ( ReferenceValue,
NewValue )
Value:

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

Definition at line 373 of file UnrealTemplate.h.

◆ STRUCT_OFFSET

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

Definition at line 223 of file UnrealTemplate.h.

◆ TEMPLATE_PARAMETERS2

#define TEMPLATE_PARAMETERS2 ( X,
Y )   X,Y

Definition at line 444 of file UnrealTemplate.h.

◆ UE_ARRAY_COUNT

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

Definition at line 217 of file UnrealTemplate.h.

◆ VTABLE_OFFSET

Definition at line 229 of file UnrealTemplate.h.

Function Documentation

◆ AsConst() [1/5]

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

Disallowed for rvalue references because it cannot extend their lifetime.

◆ AsConst() [2/5]

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

Returns a non-const reference type as const.

Definition at line 140 of file UnrealTemplate.h.

◆ AsConst() [3/5]

template<typename T >
constexpr FORCEINLINE const T * AsConst ( T *const && Ptr)
constexpr

Returns a non-const pointer type as const.

Definition at line 131 of file UnrealTemplate.h.

◆ AsConst() [4/5]

template<typename T >
constexpr FORCEINLINE const T * AsConst ( T *const & Ptr)
constexpr

Returns a non-const pointer type as const.

Definition at line 121 of file UnrealTemplate.h.

◆ AsConst() [5/5]

template<typename T , SIZE_T N>
constexpr FORCEINLINE 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.

Definition at line 156 of file UnrealTemplate.h.

◆ BitMask()

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

Generates a bitmask with a given number of bits set.

◆ BitMask< uint16 >()

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

Definition at line 651 of file UnrealTemplate.h.

◆ BitMask< uint32 >()

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

Definition at line 644 of file UnrealTemplate.h.

◆ BitMask< uint64 >()

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

Definition at line 637 of file UnrealTemplate.h.

◆ BitMask< uint8 >()

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

Definition at line 658 of file UnrealTemplate.h.

◆ CopyTemp() [1/3]

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

Definition at line 504 of file UnrealTemplate.h.

◆ CopyTemp() [2/3]

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

Definition at line 511 of file UnrealTemplate.h.

◆ CopyTemp() [3/3]

template<typename T >
FORCEINLINE 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.

Definition at line 498 of file UnrealTemplate.h.

◆ CopyTempIfNecessary()

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

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.

Definition at line 534 of file UnrealTemplate.h.

◆ 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 >
void Exchange ( T & A,
T & B )
inline

Definition at line 590 of file UnrealTemplate.h.

◆ FloatCastChecked()

OutType FloatCastChecked ( InType In,
InType Precision )

Definition at line 198 of file UnrealTemplate.h.

◆ FloatFitsIn()

constexpr bool FloatFitsIn ( InType In,
InType Precision )
constexpr

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

Definition at line 189 of file UnrealTemplate.h.

◆ Forward() [1/2]

template<typename T >
FORCEINLINE T && Forward ( typename TRemoveReference< T >::Type && Obj)

Definition at line 550 of file UnrealTemplate.h.

◆ Forward() [2/2]

template<typename T >
FORCEINLINE T && Forward ( typename TRemoveReference< T >::Type & Obj)

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

Definition at line 544 of file UnrealTemplate.h.

◆ ForwardAsBase() [1/2]

template<typename T , typename Base , decltype(ImplicitConv< const volatile Base * >((typename TRemoveReference< T >::Type *) nullptr)) * = nullptr>
FORCEINLINE decltype(auto) ForwardAsBase ( typename TRemoveReference< T >::Type && Obj)

Definition at line 727 of file UnrealTemplate.h.

◆ ForwardAsBase() [2/2]

template<typename T , typename Base , decltype(ImplicitConv< const volatile Base * >((typename TRemoveReference< T >::Type *) nullptr)) * = nullptr>
FORCEINLINE decltype(auto) ForwardAsBase ( typename TRemoveReference< T >::Type & 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.

Definition at line 717 of file UnrealTemplate.h.

◆ GetData() [1/6]

template<typename T , SIZE_T N>
constexpr const T * GetData ( const T(&&) Container[N])
constexpr

Definition at line 82 of file UnrealTemplate.h.

◆ GetData() [2/6]

template<typename T , SIZE_T N>
constexpr const T * GetData ( const T(&) Container[N])
constexpr

Definition at line 81 of file UnrealTemplate.h.

◆ GetData() [3/6]

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

Definition at line 85 of file UnrealTemplate.h.

◆ GetData() [4/6]

template<typename T , typename = typename TEnableIf<TIsContiguousContainer<T>::Value>::Type>
constexpr auto GetData ( T && Container) -> decltype(Container.GetData())
constexpr

Generically gets the data pointer of a contiguous container

Definition at line 74 of file UnrealTemplate.h.

◆ GetData() [5/6]

template<typename T , SIZE_T N>
constexpr T * GetData ( T(&&) Container[N])
constexpr

Definition at line 80 of file UnrealTemplate.h.

◆ GetData() [6/6]

template<typename T , SIZE_T N>
constexpr T * GetData ( T(&) Container[N])
constexpr

Definition at line 79 of file UnrealTemplate.h.

◆ GetNum() [1/6]

template<typename T , SIZE_T N>
constexpr SIZE_T GetNum ( const T(&&) Container[N])
constexpr

Definition at line 102 of file UnrealTemplate.h.

◆ GetNum() [2/6]

template<typename T , SIZE_T N>
constexpr SIZE_T GetNum ( const T(&) Container[N])
constexpr

Definition at line 101 of file UnrealTemplate.h.

◆ GetNum() [3/6]

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.

Definition at line 111 of file UnrealTemplate.h.

◆ GetNum() [4/6]

template<typename T , typename = typename TEnableIf<TIsContiguousContainer<T>::Value>::Type>
constexpr auto GetNum ( T && Container) -> decltype(Container.Num())
constexpr

Generically gets the number of items in a contiguous container

Definition at line 94 of file UnrealTemplate.h.

◆ GetNum() [5/6]

template<typename T , SIZE_T N>
constexpr SIZE_T GetNum ( T(&&) Container[N])
constexpr

Definition at line 100 of file UnrealTemplate.h.

◆ GetNum() [6/6]

template<typename T , SIZE_T N>
constexpr SIZE_T GetNum ( T(&) Container[N])
constexpr

Definition at line 99 of file UnrealTemplate.h.

◆ IfAThenAElseB()

Chooses between the two parameters based on whether the first is nullptr or not.

Returns
If the first parameter provided is non-nullptr, it is returned; otherwise the second parameter is returned.

Definition at line 28 of file UnrealTemplate.h.

◆ IfPThenAElseB()

branchless pointer selection based on predicate return PTRINT(Predicate) ? A : B;

Definition at line 37 of file UnrealTemplate.h.

◆ ImplicitConv()

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

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.

Definition at line 703 of file UnrealTemplate.h.

◆ IntCastChecked()

OutType IntCastChecked ( InType In)

Cast and check that value fits in OutType

Definition at line 181 of file UnrealTemplate.h.

◆ IntFitsIn()

constexpr bool IntFitsIn ( InType In)
constexpr

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

Definition at line 163 of file UnrealTemplate.h.

◆ MaxElement() [1/2]

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

works just like std::max_element.

Definition at line 271 of file UnrealTemplate.h.

◆ MaxElement() [2/2]

ForwardIt MaxElement ( ForwardIt First,
ForwardIt Last,
PredicateType Predicate )
inline

works just like std::max_element.

Definition at line 288 of file UnrealTemplate.h.

◆ MinElement() [1/2]

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

works just like std::min_element.

Definition at line 237 of file UnrealTemplate.h.

◆ MinElement() [2/2]

ForwardIt MinElement ( ForwardIt First,
ForwardIt Last,
PredicateType Predicate )
inline

works just like std::min_element.

Definition at line 254 of file UnrealTemplate.h.

◆ Move() [1/2]

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

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

Definition at line 50 of file UnrealTemplate.h.

◆ Move() [2/2]

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

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

Definition at line 61 of file UnrealTemplate.h.

◆ MoveTemp()

template<typename T >
FORCEINLINE TRemoveReference< T >::Type && MoveTemp ( T && Obj)

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.

Definition at line 464 of file UnrealTemplate.h.

◆ MoveTempIfPossible()

template<typename T >
FORCEINLINE TRemoveReference< T >::Type && MoveTempIfPossible ( T && Obj)

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.

Definition at line 482 of file UnrealTemplate.h.

◆ ReverseBits()

template<typename T >
FORCEINLINE TEnableIf< std::is_same_v< T, uint32 >, T >::Type ReverseBits ( T Bits)

Reverses the order of the bits of a value. This is an TEnableIf'd 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.

Definition at line 620 of file UnrealTemplate.h.

◆ StaticCast()

template<typename T , typename ArgType >
FORCEINLINE 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.

Definition at line 601 of file UnrealTemplate.h.

◆ Swap() [1/2]

template<typename T >
TEnableIf< TUseBitwiseSwap< T >::Value >::Type Swap ( T & A,
T & B )
inline

Swap two values. Assumes the types are trivially relocatable.

Definition at line 570 of file UnrealTemplate.h.

◆ Swap() [2/2]

template<typename T >
TEnableIf<!TUseBitwiseSwap< T >::Value >::Type Swap ( T & A,
T & B )
inline

Definition at line 582 of file UnrealTemplate.h.

◆ UEArrayCountHelper()

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

◆ XOR()

bool XOR ( bool A,
bool B )
inline

A logical exclusive or function.

Definition at line 43 of file UnrealTemplate.h.