engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
TFunction< FuncType > 模板类 参考

TFunction<FuncType> 更多...

#include <Function.h>

+ 类 TFunction< FuncType > 继承关系图:

Public 成员函数

FORCEINLINE operator bool () const
 Tests if the TFunction is callable.
 
TFunction & operator= (const TFunction &Other)
 Copy assignment operator.
 
TFunction & operator= (TFunction &&Other)
 Move assignment operator.
 
template<typename FunctorType , typename = typename TEnableIf< TAnd< TNot<TIsTFunction<typename TDecay<FunctorType>::Type>>, UE4Function_Private::TFuncCanBindToFunctor<FuncType, FunctorType> >::Value >::Type>
 TFunction (FunctorType &&InFunc)
 Constructor which binds a TFunction to any function object.
 
 TFunction (TYPE_OF_NULLPTR=nullptr)
 Default constructor.
 

详细描述

template<typename FuncType>
class TFunction< FuncType >

TFunction<FuncType>

See the class definition for intended usage.

A class which represents a copy of something callable. FuncType represents a function type and so TFunction should be defined as follows:

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

Unlike TFunctionRef, this object is intended to be used like a UE4 version of std::function. That is, it takes a copy of whatever is bound to it, meaning you can return it from functions and store them in objects without caring about the lifetime of the original object being bound.

Example:

// Something.h TFunction<FString (int32)> GetTransform();

// Something.cpp TFunction<FString (int32)> GetTransform(const FString& Prefix) { // Squares number and returns it as a string with the specified prefix return [=](int32 Num) { return Prefix + TEXT(": ") + TTypeToString<int32>::ToString(Num * Num); }; }

// SomewhereElse.cpp #include "Something.h"

void Func() { TFunction<FString (int32)> Transform = GetTransform(TEXT("Hello"));

FString Result = Transform(5); // "Hello: 25" }


该类的文档由以下文件生成: