13#include "Templates/Invoke.h"
21#if defined(UE_ENABLE_TFUNCTIONREF_VISUALIZATION) && UE_ENABLE_TFUNCTIONREF_VISUALIZATION
22 COMPILE_WARNING(
"TFunction visualization has been removed - please undefine UE_ENABLE_TFUNCTIONREF_VISUALIZATION.")
25#if !defined(NUM_TFUNCTION_INLINE_BYTES) || NUM_TFUNCTION_INLINE_BYTES == 0
26 #define TFUNCTION_USES_INLINE_STORAGE 0
28 #define TFUNCTION_USES_INLINE_STORAGE 1
29 #define TFUNCTION_INLINE_SIZE NUM_TFUNCTION_INLINE_BYTES
30 #define TFUNCTION_INLINE_ALIGNMENT 16
38 template <
typename T,
bool bUnique,
bool bOnHeap>
39 struct TFunction_OwnedObject;
41 struct FFunctionStorage;
43 template <
bool bUnique>
44 struct TFunctionStorage;
72 template <
typename T,
bool bUnique,
bool bOnHeap>
75 template <
typename ArgType>
111 template <
typename T>
129 constexpr static bool bCanBeNull =
true;
132 : HeapAllocation(nullptr)
137 : HeapAllocation(
Other.HeapAllocation)
139 Other.HeapAllocation =
nullptr;
140 #if TFUNCTION_USES_INLINE_STORAGE
151 Other.GetBoundObject()->CloneToEmptyStorage(
this);
157 #if TFUNCTION_USES_INLINE_STORAGE
172 #if TFUNCTION_USES_INLINE_STORAGE
194 #if TFUNCTION_USES_INLINE_STORAGE
202 template <
bool bUnique>
212 template <
typename FunctorType>
222#if TFUNCTION_USES_INLINE_STORAGE
231#if TFUNCTION_USES_INLINE_STORAGE
249 template <
typename T,
bool bUnique,
bool bOnHeap>
263#if TFUNCTION_USES_INLINE_STORAGE
266 NewAlloc = &Storage.InlineAllocation;
285 template <
typename Functor,
typename Ret,
typename... ParamTypes>
288 static Ret
Call(
void* Obj, ParamTypes&... Params)
290 if constexpr (std::is_void_v<Ret>)
311 template <
typename StorageType,
typename FuncType>
314 template <
typename StorageType,
typename Ret,
typename... ParamTypes>
317 template <
typename OtherStorageType,
typename OtherFuncType>
323 : Callable(
Other.Callable)
326 static_assert(StorageType::bCanBeNull,
"Unable to move non-nullable storage");
330 Other.Callable =
nullptr;
334 template <
typename OtherStorage>
336 : Callable(
Other.Callable)
339 static_assert(OtherStorage::bCanBeNull,
"Unable to move from non-nullable storage");
340 static_assert(StorageType::bCanBeNull,
"Unable to move into non-nullable storage");
344 Other.Callable =
nullptr;
348 template <
typename OtherStorage>
350 : Callable(
Other.Callable)
352 if constexpr (OtherStorage::bCanBeNull)
354 static_assert(StorageType::bCanBeNull,
"Unable to copy from nullable storage into non-nullable storage");
362 Storage.BindCopy(
Other.Storage);
366 : Callable(
Other.Callable)
368 if constexpr (StorageType::bCanBeNull)
376 Storage.BindCopy(
Other.Storage);
379 template <UE::CNotCVRefTo<TFunctionRefBase> FunctorType>
384 if constexpr (StorageType::bCanBeNull)
400 UE_DEPRECATED(5.7,
"CheckCallable should not be called - use check(Func) instead, and for a TFunctionRef there's no need to check.")
403 checkf(Callable,
TEXT(
"Attempting to call an unbound TFunction!"));
409 if constexpr (StorageType::bCanBeNull)
414 return Callable(Storage.GetPtr(), Params...);
419 if constexpr (StorageType::bCanBeNull)
452 Ret (*Callable)(
void*, ParamTypes&...) =
nullptr;
461 template <
typename FunctorType>
462 std::remove_reference_t<FunctorType>*
Bind(FunctorType&&
InFunc)
499 template <
typename FunctorType>
555template <
typename Ret,
typename... ParamTypes>
564 template <
typename FunctorType>
578 constexpr static bool bHasIntrusiveUnsetOptionalState =
true;
586 return !Super::IsSet();
638template <
typename Ret,
typename... ParamTypes>
654 template <
typename FunctorType>
709 return Super::IsSet();
717 return Super::IsSet();
753template <
typename Ret,
typename... ParamTypes>
769 template <
typename FunctorType>
830 return Super::IsSet();
838 return Super::IsSet();
843#if !PLATFORM_COMPILER_HAS_GENERATED_COMPARISON_OPERATORS
847template <
typename FuncType>
856template <
typename FuncType>
863#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define AUTORTFM_INFER
Definition AutoRTFMDefines.h:121
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define CA_ASSUME(Expr)
Definition CoreMiscDefines.h:126
FORCEINLINE bool operator==(TYPE_OF_NULLPTR, const TFunction< FuncType > &Func)
Definition Function.h:848
FORCEINLINE bool operator!=(TYPE_OF_NULLPTR, const TFunction< FuncType > &Func)
Definition Function.h:857
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition Core.Build.cs:8
TFunctionRef(FunctorType &&InFunc UE_LIFETIMEBOUND)
Definition Function.h:566
TFunctionRef(FIntrusiveUnsetOptionalState)
Definition Function.h:581
TFunctionRef & operator=(const TFunctionRef &) const =delete
bool operator==(FIntrusiveUnsetOptionalState) const
Definition Function.h:584
TFunctionRef(const TFunctionRef &)=default
Definition AssetRegistryState.h:50
TFunction & operator=(TFunction &&Other)
Definition Function.h:679
TFunction(TFunction &&)=default
TFunction & operator=(TYPE_OF_NULLPTR)
Definition Function.h:698
TFunction & operator=(const TFunction &Other)
Definition Function.h:688
FORCEINLINE bool IsSet() const
Definition Function.h:715
TFunction(TYPE_OF_NULLPTR=nullptr)
Definition Function.h:647
FORCEINLINE bool operator==(TYPE_OF_NULLPTR) const
Definition Function.h:723
TFunction(const TFunction &Other)=default
FORCEINLINE bool operator!=(TYPE_OF_NULLPTR) const
Definition Function.h:731
TFunction(FunctorType &&InFunc)
Definition Function.h:656
Definition AndroidPlatformMisc.h:14
TUniqueFunction & operator=(TUniqueFunction &&Other)
Definition Function.h:806
TUniqueFunction(const TUniqueFunction &Other)=delete
FORCEINLINE bool IsSet() const
Definition Function.h:836
TUniqueFunction(TFunction< Ret(ParamTypes...)> &&Other)
Definition Function.h:790
TUniqueFunction(TYPE_OF_NULLPTR=nullptr)
Definition Function.h:762
~TUniqueFunction()=default
TUniqueFunction & operator=(const TUniqueFunction &Other)=delete
TUniqueFunction(const TFunction< Ret(ParamTypes...)> &Other)
Definition Function.h:798
void Reset()
Definition Function.h:820
TUniqueFunction(FunctorType &&InFunc)
Definition Function.h:771
TUniqueFunction(TUniqueFunction &&)=default
Definition FunctionFwd.h:19
Definition OverriddenPropertySet.cpp:45
Definition Function.cpp:6
decltype(ResolveFuncPtrTypeIfPossible(std::declval< FunctorType && >(), 0)) TFuncPtrTypeIfPossible_T
Definition Function.h:500
FORCEINLINE bool IsBound(const T &Func)
Definition Function.h:112
FORCENOINLINE void CheckCallable(void *Callable)
Definition Function.cpp:7
auto ResolveFuncPtrTypeIfPossible(FunctorType &&, int) -> decltype(+std::declval< FunctorType >())
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition IntrusiveUnsetOptionalState.h:71
static FORCENOINLINE CORE_API void Free(void *Original)
Definition UnrealMemory.cpp:685
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160
Definition FunctionFwd.h:52
Definition FunctionFwd.h:32
Definition FunctionFwd.h:42
Definition UnrealTemplate.h:511
Definition Function.h:458
void * GetPtr() const
Definition Function.h:478
std::remove_reference_t< FunctorType > * Bind(FunctorType &&InFunc)
Definition Function.h:462
static constexpr bool bCanBeNull
Definition Function.h:459
void Unbind() const
Definition Function.h:486
void BindCopy(const FFunctionRefStoragePolicy &Other)
Definition Function.h:470
Definition Function.h:128
FFunctionStorage & operator=(const FFunctionStorage &Other)=delete
void BindCopy(const FFunctionStorage &Other)
Definition Function.h:149
void * HeapAllocation
Definition Function.h:199
FFunctionStorage(FFunctionStorage &&Other)
Definition Function.h:136
void * GetPtr() const
Definition Function.h:170
FFunctionStorage()
Definition Function.h:131
FFunctionStorage(const FFunctionStorage &Other)=delete
FFunctionStorage & operator=(FFunctionStorage &&Other)=delete
void Unbind()
Definition Function.h:188
IFunction_OwnedObject * GetBoundObject() const
Definition Function.h:154
virtual void * CloneToEmptyStorage(FFunctionStorage *Storage) const =0
virtual void * GetAddress()=0
virtual ~IFunction_OwnedObject()=default
TFunctionRefBase(const TFunctionRefBase &Other)
Definition Function.h:365
TFunctionRefBase()=default
TFunctionRefBase(FunctorType &&InFunc)
Definition Function.h:380
TFunctionRefBase(TFunctionRefBase< OtherStorage, Ret(ParamTypes...)> &&Other)
Definition Function.h:335
TFunctionRefBase & operator=(TFunctionRefBase &&)=delete
TFunctionRefBase(TFunctionRefBase &&Other)
Definition Function.h:322
Ret operator()(ParamTypes... Params) const
Definition Function.h:406
void Reset()
Definition Function.h:432
bool IsSet() const
Definition Function.h:442
TFunctionRefBase & operator=(const TFunctionRefBase &)=delete
~TFunctionRefBase()
Definition Function.h:417
TFunctionRefBase(const TFunctionRefBase< OtherStorage, Ret(ParamTypes...)> &Other)
Definition Function.h:349
Definition Function.h:312
Definition Function.h:287
static Ret Call(void *Obj, ParamTypes &... Params)
Definition Function.h:288
Definition Function.h:204
TFunctionStorage()=default
TFunctionStorage(FFunctionStorage &&Other)
Definition Function.h:207
std::decay_t< FunctorType > * Bind(FunctorType &&InFunc)
Definition Function.h:213
virtual void * GetAddress() override
Definition Function.h:81
~TFunction_OwnedObject() override
Definition Function.h:102
void * CloneToEmptyStorage(FFunctionStorage *UntypedStorage) const override
Definition Function.h:250
virtual void Destroy() override
Definition Function.h:88
TFunction_OwnedObject(ArgType &&Arg)
Definition Function.h:76
T Obj
Definition Function.h:108