Navigation
API > API/Runtime > API/Runtime/Core
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
The example ParseLines can be called as:
ParseLines(Input, FStringView Line { PrintLine(Line); });
| Name | TFunctionWithContext |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Templates/FunctionWithContext.h |
| Include Path | #include "Templates/FunctionWithContext.h" |
Syntax
template<typename FunctionType>
class TFunctionWithContext
Class Specializations
| Name | Remarks |
|---|---|
| TFunctionWithContext< ReturnType(ArgTypes...)> |