Ark Server API (ASE) - Wiki
|
#include <Function.h>
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) | |
TFunction & | operator= (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 > |
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.
|
private |
Definition at line 540 of file Function.h.
|
inline |
Default constructor.
Definition at line 546 of file Function.h.
|
inline |
Constructor which binds a TFunction to any function object.
Definition at line 556 of file Function.h.
|
inline |
Copy constructor.
Definition at line 581 of file Function.h.
|
inline |
Move constructor.
Definition at line 598 of file Function.h.
Destructor.
Definition at line 632 of file Function.h.
|
inlineprivate |
Returns a pointer to the callable object - needed by TFunctionRefBase.
Definition at line 652 of file Function.h.
|
inlineexplicit |
Tests if the TFunction is callable.
Definition at line 643 of file Function.h.
|
inline |
Nullptr assignment operator - unbinds any bound function.
Definition at line 617 of file Function.h.
|
friend |
Definition at line 495 of file Function.h.
|
private |
Definition at line 658 of file Function.h.