UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
uLang::TFunctionRef< FuncType > Class Template Reference

#include <Function.h>

+ Inheritance diagram for uLang::TFunctionRef< FuncType >:

Public Member Functions

template<typename FunctorType , typename = typename TEnableIf< TAnd< TNot<TIsTFunctionRef<typename TDecay<FunctorType>::Type>>, Private::TFuncCanBindToFunctor<FuncType, typename TDecay<FunctorType>::Type> >::Value >::Type>
 TFunctionRef (FunctorType &&InFunc)
 
 TFunctionRef (const TFunctionRef &)=default
 
TFunctionRefoperator= (const TFunctionRef &) const =delete
 
 ~TFunctionRef ()=default
 

Detailed Description

template<typename FuncType>
class uLang::TFunctionRef< FuncType >

TFunctionRef<FuncType>

See the class definition for intended usage.

TFunctionRef<FuncType>

A class which represents a reference to something callable. The important part here is reference - if you bind it to a lambda and the lambda goes out of scope, you will be left with an invalid reference.

FuncType represents a function type and so TFunctionRef should be defined as follows:

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

If you also want to take ownership of the callable thing, e.g. you want to return a lambda from a function, you should use TFunction. TFunctionRef does not concern itself with ownership because it's intended to be FAST.

TFunctionRef is most useful when you want to parameterize a function with some caller-defined code without making it a template.

Example:

// Something.h void DoSomethingWithConvertingStringsToInts(TFunctionRef<int32 (const FString& Str)> Convert);

// Something.cpp void DoSomethingWithConvertingStringsToInts(TFunctionRef<int32 (const FString& Str)> Convert) { for (const FString& Str : SomeBunchOfStrings) { int32 Int = Convert(Str); DoSomething(Int); } }

// SomewhereElse.cpp include "Something.h"

void Func() { // First do something using string length DoSomethingWithConvertingStringsToInts([](const FString& Str) { return Str.Len(); });

// Then do something using string conversion DoSomethingWithConvertingStringsToInts([](const FString& Str) { int32 Result; TTypeFromString<int32>::FromString(Result, *Str); return Result; }); }

Constructor & Destructor Documentation

◆ TFunctionRef() [1/2]

template<typename FuncType >
template<typename FunctorType , typename = typename TEnableIf< TAnd< TNot<TIsTFunctionRef<typename TDecay<FunctorType>::Type>>, Private::TFuncCanBindToFunctor<FuncType, typename TDecay<FunctorType>::Type> >::Value >::Type>
uLang::TFunctionRef< FuncType >::TFunctionRef ( FunctorType &&  InFunc)
inline

Constructor which binds a TFunctionRef to a callable object.

◆ TFunctionRef() [2/2]

template<typename FuncType >
uLang::TFunctionRef< FuncType >::TFunctionRef ( const TFunctionRef< FuncType > &  )
default

◆ ~TFunctionRef()

template<typename FuncType >
uLang::TFunctionRef< FuncType >::~TFunctionRef ( )
default

Member Function Documentation

◆ operator=()

template<typename FuncType >
TFunctionRef & uLang::TFunctionRef< FuncType >::operator= ( const TFunctionRef< FuncType > &  ) const
delete

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