DoSomethingWithConvertingStringsToInts

TFunctionRef

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Templates/Function.h

Include

#include "Templates/Function.h"

Syntax

*void DoSomethingWithConvertingStringsToInts
(
    TFunctionRef< int32 &Str)> Convert
)

Remarks

TFunctionRef

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

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 Convert);

// Something.cpp /** TFunctionRef

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

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 Convert);

// Something.cpp /**

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss