Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
UnrealTemplate.h File Reference
#include "../BasicTypes.h"
#include "IsPointer.h"
#include "../HAL/UnrealMemory.h"
#include "EnableIf.h"
#include "AndOrNot.h"
#include "AreTypesEqual.h"
#include "IsArithmetic.h"
#include "UnrealTypeTraits.h"
#include "RemoveReference.h"
#include "TypeCompatibleBytes.h"
#include "IsContiguousContainer.h"
+ Include dependency graph for UnrealTemplate.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FNoncopyable
 
struct  TGuardValue< Type >
 
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
 
struct  TCopyQualifiersFromTo< From, To >
 
struct  TCopyQualifiersFromTo< const From, To >
 
struct  TCopyQualifiersFromTo< volatile From, To >
 
struct  TCopyQualifiersFromTo< const volatile From, To >
 
struct  TLosesQualifiersFromTo< From, To >
 
struct  TIdentity< T >
 

Macros

#define ARRAY_COUNT(array)   (sizeof(ArrayCountHelper(array)) - 1)
 
#define STRUCT_OFFSET(struc, member)   offsetof(struc, member)
 
#define VTABLE_OFFSET(Class, MultipleInheritenceParent)   ( ((PTRINT) static_cast<MultipleInheritenceParent*>((Class*)1)) - 1)
 
#define TEMPLATE_PARAMETERS2(X, Y)   X,Y
 

Functions

template<typename ReferencedType >
FORCEINLINE ReferencedType * IfAThenAElseB (ReferencedType *A, ReferencedType *B)
 
template<typename PredicateType , typename ReferencedType >
FORCEINLINE ReferencedType * IfPThenAElseB (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>
auto GetData (T &&Container) -> decltype(Container.GetData())
 
template<typename T , SIZE_T N>
CONSTEXPR T * GetData (T(&Container)[N])
 
template<typename T >
CONSTEXPR T * GetData (std::initializer_list< T > List)
 
template<typename T , typename = typename TEnableIf<TIsContiguousContainer<T>::Value>::Type>
SIZE_T GetNum (T &&Container)
 
template<typename T , SIZE_T N>
CONSTEXPR SIZE_T GetNum (T(&Container)[N])
 
template<typename T >
CONSTEXPR SIZE_T GetNum (std::initializer_list< T > List)
 
template<typename T , uint32 N>
char(& ArrayCountHelper (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 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< TAreTypesEqual< T, uint32 >::Value, T >::Type ReverseBits (T Bits)
 
template<typename T >
T && DeclVal ()
 

Macro Definition Documentation

◆ ARRAY_COUNT

#define ARRAY_COUNT ( array)    (sizeof(ArrayCountHelper(array)) - 1)

Definition at line 135 of file UnrealTemplate.h.

◆ STRUCT_OFFSET

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

Definition at line 143 of file UnrealTemplate.h.

◆ TEMPLATE_PARAMETERS2

#define TEMPLATE_PARAMETERS2 ( X,
Y )   X,Y

Definition at line 343 of file UnrealTemplate.h.

◆ VTABLE_OFFSET

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

Definition at line 151 of file UnrealTemplate.h.

Function Documentation

◆ ArrayCountHelper()

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

◆ CopyTemp() [1/3]

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

Definition at line 399 of file UnrealTemplate.h.

◆ CopyTemp() [2/3]

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

Definition at line 405 of file UnrealTemplate.h.

◆ CopyTemp() [3/3]

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

CopyTemp will enforce the creation of an rvalue which can bind to rvalue reference parameters. Unlike MoveTemp, the source object will never be modifed. (i.e. a copy will be made) There is no std:: equivalent.

Definition at line 393 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.

+ Here is the caller graph for this function:

◆ Exchange()

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

Definition at line 465 of file UnrealTemplate.h.

◆ Forward() [1/2]

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

Definition at line 422 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 416 of file UnrealTemplate.h.

◆ GetData() [1/3]

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

Definition at line 96 of file UnrealTemplate.h.

◆ GetData() [2/3]

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

Generically gets the data pointer of a contiguous container

Definition at line 84 of file UnrealTemplate.h.

◆ GetData() [3/3]

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

Definition at line 90 of file UnrealTemplate.h.

◆ GetNum() [1/3]

template<typename T >
CONSTEXPR SIZE_T GetNum ( std::initializer_list< T > List)

Definition at line 117 of file UnrealTemplate.h.

◆ GetNum() [2/3]

template<typename T , typename = typename TEnableIf<TIsContiguousContainer<T>::Value>::Type>
SIZE_T GetNum ( T && Container)

Generically gets the number of items in a contiguous container

Definition at line 105 of file UnrealTemplate.h.

◆ GetNum() [3/3]

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

Definition at line 111 of file UnrealTemplate.h.

◆ IfAThenAElseB()

template<typename ReferencedType >
FORCEINLINE ReferencedType * IfAThenAElseB ( ReferencedType * A,
ReferencedType * B )

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 26 of file UnrealTemplate.h.

◆ IfPThenAElseB()

template<typename PredicateType , typename ReferencedType >
FORCEINLINE ReferencedType * IfPThenAElseB ( PredicateType Predicate,
ReferencedType * A,
ReferencedType * B )

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

Definition at line 41 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 193 of file UnrealTemplate.h.

◆ MaxElement() [2/2]

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

works just like std::max_element.

Definition at line 210 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 159 of file UnrealTemplate.h.

◆ MinElement() [2/2]

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

works just like std::min_element.

Definition at line 176 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 60 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 71 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 363 of file UnrealTemplate.h.

+ Here is the caller graph for this function:

◆ MoveTempIfPossible()

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

MoveTemp 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 381 of file UnrealTemplate.h.

◆ ReverseBits()

template<typename T >
FORCEINLINE TEnableIf< TAreTypesEqual< T, uint32 >::Value, 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 495 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 476 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 442 of file UnrealTemplate.h.

◆ Swap() [2/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 457 of file UnrealTemplate.h.

◆ XOR()

bool XOR ( bool A,
bool B )
inline

A logical exclusive or function.

Definition at line 53 of file UnrealTemplate.h.