Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TFunction< FuncType > Class Template Reference

#include <Function.h>

+ Inheritance diagram for TFunction< FuncType >:
+ Collaboration diagram for TFunction< FuncType >:

Public Member Functions

 TFunction (TYPE_OF_NULLPTR=nullptr)
 
template<typename FunctorType , typename = typename TEnableIf< TAnd< TNot<TIsTFunction<typename TDecay<FunctorType>::Type>>, UE::Core::Private::Function::TFuncCanBindToFunctor<FuncType, FunctorType> >::Value >::Type>
 TFunction (FunctorType &&InFunc)
 
 TFunction (TFunction &&)=default
 
 TFunction (const TFunction &Other)=default
 
 ~TFunction ()=default
 
TFunctionoperator= (TFunction &&Other)
 
TFunctionoperator= (const TFunction &Other)
 
void Reset ()
 
FORCEINLINE operator bool () const
 
FORCEINLINE bool operator== (TYPE_OF_NULLPTR) const
 
FORCEINLINE bool operator!= (TYPE_OF_NULLPTR) const
 

Private Types

using Super = UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<false>, FuncType>
 

Detailed Description

template<typename FuncType>
class TFunction< FuncType >

TFunction<FuncType>

See the class definition for intended usage.

TFunction<FuncType>

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 UE 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" }

Definition at line 839 of file Function.h.

Member Typedef Documentation

◆ Super

Definition at line 841 of file Function.h.

Constructor & Destructor Documentation

◆ TFunction() [1/4]

template<typename FuncType >
TFunction< FuncType >::TFunction ( TYPE_OF_NULLPTR = nullptr)
inline

Default constructor.

Definition at line 847 of file Function.h.

◆ TFunction() [2/4]

template<typename FuncType >
template<typename FunctorType , typename = typename TEnableIf< TAnd< TNot<TIsTFunction<typename TDecay<FunctorType>::Type>>, UE::Core::Private::Function::TFuncCanBindToFunctor<FuncType, FunctorType> >::Value >::Type>
TFunction< FuncType >::TFunction ( FunctorType && InFunc)
inline

Constructor which binds a TFunction to any function object.

Definition at line 863 of file Function.h.

◆ TFunction() [3/4]

template<typename FuncType >
TFunction< FuncType >::TFunction ( TFunction< FuncType > && )
default

◆ TFunction() [4/4]

template<typename FuncType >
TFunction< FuncType >::TFunction ( const TFunction< FuncType > & Other)
default

◆ ~TFunction()

template<typename FuncType >
TFunction< FuncType >::~TFunction ( )
default

Member Function Documentation

◆ operator bool()

template<typename FuncType >
FORCEINLINE TFunction< FuncType >::operator bool ( ) const
inlineexplicit

Tests if the TFunction is callable.

Definition at line 913 of file Function.h.

◆ operator!=()

template<typename FuncType >
FORCEINLINE bool TFunction< FuncType >::operator!= ( TYPE_OF_NULLPTR ) const
inline

Nullptr inequality operator.

Definition at line 929 of file Function.h.

◆ operator=() [1/2]

template<typename FuncType >
TFunction & TFunction< FuncType >::operator= ( const TFunction< FuncType > & Other)
inline

Copy assignment operator.

Definition at line 895 of file Function.h.

◆ operator=() [2/2]

template<typename FuncType >
TFunction & TFunction< FuncType >::operator= ( TFunction< FuncType > && Other)
inline

Move assignment operator.

Definition at line 886 of file Function.h.

◆ operator==()

template<typename FuncType >
FORCEINLINE bool TFunction< FuncType >::operator== ( TYPE_OF_NULLPTR ) const
inline

Nullptr equality operator.

Definition at line 921 of file Function.h.

◆ Reset()

template<typename FuncType >
void TFunction< FuncType >::Reset ( )
inline

Removes any bound callable from the TFunction, restoring it to the default 'empty' state.

Definition at line 905 of file Function.h.


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