Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
TFunction< FuncType > Class Template Reference

#include <Function.h>

+ Inheritance diagram for TFunction< FuncType >:
+ Collaboration diagram for TFunction< FuncType >:

Public Member Functions

 TFunction (TYPE_OF_NULLPTR=nullptr)
 
template<typename FunctorType , typename = typename TEnableIf<!TAreTypesEqual<TFunction, typename TDecay<FunctorType>::Type>::Value>::Type>
 TFunction (FunctorType &&InFunc)
 
 TFunction (const TFunction &Other)
 
 TFunction (TFunction &&Other)
 
TFunctionoperator= (TYPE_OF_NULLPTR)
 
 ~TFunction ()
 
FORCEINLINE operator bool () const
 

Private Types

typedef UE4Function_Private::TFunctionRefBase< TFunction< FuncType >, FuncType > Super
 

Private Member Functions

void * GetPtr () const
 

Private Attributes

UE4Function_Private::FFunctionStorage Storage
 

Friends

struct UE4Function_Private::TFunctionRefBase< TFunction< FuncType >, FuncType >
 

Detailed Description

template<typename FuncType>
class TFunction< FuncType >

TFunction<FuncType>

See the class definition for intended usage.

TFunction<FuncType>

A class which represents a copy of something callable. FuncType represents a function type and so TFunction should be defined as follows:

// A function taking a string and float and returning int32. Parameter names are optional. TFunction<int32 (const FString& Name, float Scale)>

Unlike TFunctionRef, this object is intended to be used like a UE4 version of std::function. That is, it takes a copy of whatever is bound to it, meaning you can return it from functions and store them in objects without caring about the lifetime of the original object being bound.

Example:

// Something.h TFunction<FString (int32)> GetTransform();

// Something.cpp TFunction<FString (int32)> GetTransform(const FString& Prefix) { // Squares number and returns it as a string with the specified prefix return [=](int32 Num) { return Prefix + TEXT(": ") + TTypeToString<int32>::ToString(Num * Num); }; }

// SomewhereElse.cpp #include "Something.h"

void Func() { TFunction<FString (int32)> Transform = GetTransform(TEXT("Hello"));

FString Result = Transform(5); // "Hello: 25" }

Definition at line 536 of file Function.h.

Member Typedef Documentation

◆ Super

template<typename FuncType >
typedef UE4Function_Private::TFunctionRefBase<TFunction<FuncType>, FuncType> TFunction< FuncType >::Super
private

Definition at line 540 of file Function.h.

Constructor & Destructor Documentation

◆ TFunction() [1/4]

template<typename FuncType >
TFunction< FuncType >::TFunction ( TYPE_OF_NULLPTR = nullptr)
inline

Default constructor.

Definition at line 546 of file Function.h.

◆ TFunction() [2/4]

template<typename FuncType >
template<typename FunctorType , typename = typename TEnableIf<!TAreTypesEqual<TFunction, typename TDecay<FunctorType>::Type>::Value>::Type>
TFunction< FuncType >::TFunction ( FunctorType && InFunc)
inline

Constructor which binds a TFunction to any function object.

Definition at line 556 of file Function.h.

◆ TFunction() [3/4]

template<typename FuncType >
TFunction< FuncType >::TFunction ( const TFunction< FuncType > & Other)
inline

Copy constructor.

Definition at line 581 of file Function.h.

◆ TFunction() [4/4]

template<typename FuncType >
TFunction< FuncType >::TFunction ( TFunction< FuncType > && Other)
inline

Move constructor.

Definition at line 598 of file Function.h.

◆ ~TFunction()

template<typename FuncType >
TFunction< FuncType >::~TFunction ( )
inline

Destructor.

Definition at line 632 of file Function.h.

Member Function Documentation

◆ GetPtr()

template<typename FuncType >
void * TFunction< FuncType >::GetPtr ( ) const
inlineprivate

Returns a pointer to the callable object - needed by TFunctionRefBase.

Definition at line 652 of file Function.h.

◆ operator bool()

template<typename FuncType >
FORCEINLINE TFunction< FuncType >::operator bool ( ) const
inlineexplicit

Tests if the TFunction is callable.

Definition at line 643 of file Function.h.

◆ operator=()

template<typename FuncType >
TFunction & TFunction< FuncType >::operator= ( TYPE_OF_NULLPTR )
inline

Nullptr assignment operator - unbinds any bound function.

Definition at line 617 of file Function.h.

Friends And Related Symbol Documentation

◆ UE4Function_Private::TFunctionRefBase< TFunction< FuncType >, FuncType >

template<typename FuncType >
friend struct UE4Function_Private::TFunctionRefBase< TFunction< FuncType >, FuncType >
friend

Definition at line 495 of file Function.h.

Member Data Documentation

◆ Storage

template<typename FuncType >
UE4Function_Private::FFunctionStorage TFunction< FuncType >::Storage
private

Definition at line 658 of file Function.h.


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