![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <Function.h>
Inheritance diagram for uLang::TFunction< FuncType >:Public Member Functions | |
| TFunction (NullPtrType=nullptr) | |
| template<typename FunctorType , typename = typename TEnableIf< TAnd< TNot<TIsTFunction<typename TDecay<FunctorType>::Type>>, Private::TFuncCanBindToFunctor<FuncType, FunctorType> >::Value >::Type> | |
| TFunction (FunctorType &&InFunc) | |
| TFunction (TFunction &&)=default | |
| TFunction (const TFunction &Other)=default | |
| ~TFunction ()=default | |
| TFunction & | operator= (TFunction &&Other) |
| TFunction & | operator= (const TFunction &Other) |
| void | Reset () |
| ULANG_FORCEINLINE | operator bool () const |
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 UE 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" }
|
inline |
Default constructor.
|
inline |
Constructor which binds a TFunction to any function object.
|
default |
|
default |
|
default |
|
inlineexplicit |
Tests if the TFunction is callable.
|
inline |
Copy assignment operator.
|
inline |
Move assignment operator.
|
inline |
Removes any bound callable from the TFunction, restoring it to the default 'empty' state.