UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::TFunctionWithContext< FunctionType > Class Template Reference

Detailed Description

template<typename FunctionType>
class UE::TFunctionWithContext< FunctionType >

Type that adapts a callable into a function pointer with a context pointer.

This does not take ownership of the callable. If constructed with a lambda, it is only valid until the lambda goes out of scope. Use TFunction to take ownership of the lambda.

This behaves like a nullable TFunctionRef with the addition of accessors to pass on the function and context pointers to implementation functions. This tends to generate more efficient code than when passing a TFunctionRef or a TFunctionWithContext either by value or by reference.

A function taking a string and float and returning int32 usage might be:

void ParseLines(FStringView View, void (Visitor)(void Context, FStringView Line), void* Context); inline void ParseLines(FStringView View, TFunctionWithContext<void (FStringView Line)> Visitor) { ParseLines(View, Visitor.GetFunction(), Visitor.GetContext()); }

The example ParseLines can be called as:

ParseLines(Input, [](FStringView Line) { PrintLine(Line); });


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