Navigation
API > API/Runtime > API/Runtime/uLangCore
TFunctionRef
See the class definition for intended usage.
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
// Something.cpp void DoSomethingWithConvertingStringsToInts(TFunctionRef
// 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
| Name | TFunctionRef |
| Type | class |
| Header File | /Engine/Source/Runtime/Solaris/uLangCore/Public/uLang/Common/Containers/Function.h |
| Include Path | #include "uLang/Common/Containers/Function.h" |
Syntax
template<typename FuncType>
class TFunctionRef : public uLang::Private::TFunctionRefBase< Private::FFunctionRefStoragePolicy, FuncType >
Inheritance Hierarchy
- TFunctionRef
- TFunctionRefBase → TFunctionRef
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TFunctionRef
(
FunctorType&& InFunc |
Constructor which binds a TFunctionRef to a callable object. | uLang/Common/Containers/Function.h | |
TFunctionRef
(
const TFunctionRef& |
uLang/Common/Containers/Function.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TFunctionRef() |
uLang/Common/Containers/Function.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| Super | Private::TFunctionRefBase< Private::FFunctionRefStoragePolicy, FuncType > | uLang/Common/Containers/Function.h |
Functions
Public
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TFunctionRef & operator=
(
const TFunctionRef& |
We delete the assignment operators because we don't want it to be confused with being related to regular C++ reference assignment - i.e. calling the assignment operator of whatever the reference is bound to - because that's not what TFunctionRef does, nor is it even capable of doing that. | uLang/Common/Containers/Function.h |