UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DelegateInstanceInterface.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7#include "Templates/Tuple.h"
8
10
11template <typename FuncType, typename UserPolicy>
13
14template <typename>
15class TDelegateBase;
16
20
21template <typename RetType, typename... ArgTypes, typename UserPolicy>
22struct IBaseDelegateInstance<RetType(ArgTypes...), UserPolicy> : public UserPolicy::FDelegateInstanceExtras
23{
30
34 virtual RetType Execute(ArgTypes...) const = 0;
35
41 // NOTE: Currently only delegates with no return value support ExecuteIfSafe()
42 virtual bool ExecuteIfSafe(ArgTypes...) const = 0;
43};
44
45// Temp workaround for deprecation warnings being emitted by this template with VS2022 17.9. Reported fixed in 17.10
47
48template <bool Const, typename Class, typename FuncType>
50
51template <typename Class, typename RetType, typename... ArgTypes>
52struct TMemFunPtrType<false, Class, RetType(ArgTypes...)>
53{
54 typedef RetType (Class::* Type)(ArgTypes...);
55};
56
57template <typename Class, typename RetType, typename... ArgTypes>
58struct TMemFunPtrType<true, Class, RetType(ArgTypes...)>
59{
60 typedef RetType (Class::* Type)(ArgTypes...) const;
61};
62
64// End temp workaround
65
66template <typename FuncType>
67struct TPayload;
68
69template <typename Ret, typename... Types>
70struct TPayload<Ret(Types...)>
71{
72 TTuple<Types..., Ret> Values;
73
74 template <typename... ArgTypes>
75 explicit TPayload(ArgTypes&&... Args)
76 : Values(Forward<ArgTypes>(Args)..., Ret())
77 {
78 }
79
80 Ret& GetResult()
81 {
82 return Values.template Get<sizeof...(Types)>();
83 }
84};
85
86template <typename... Types>
87struct TPayload<void(Types...)>
88{
89 TTuple<Types...> Values;
90
91 template <typename... ArgTypes>
92 explicit TPayload(ArgTypes&&... Args)
93 : Values(Forward<ArgTypes>(Args)...)
94 {
95 }
96
97 void GetResult()
98 {
99 }
100};
101
102template <typename T>
104{
106 : bConstructed(false)
107 {
108 }
109
111 {
112 if (bConstructed)
113 {
114 // We need a typedef here because VC won't compile the destructor call below if T itself has a member called T
116
117 ((TPlacementNewerTTypeTypedef*)&Bytes)->TPlacementNewerTTypeTypedef::~TPlacementNewerTTypeTypedef();
118 }
119 }
120
121 template <typename... ArgTypes>
122 T* operator()(ArgTypes&&... Args)
123 {
124 check(!bConstructed);
125 T* Result = new (&Bytes) T(Forward<ArgTypes>(Args)...);
126 bConstructed = true;
127 return Result;
128 }
129
131 {
132 check(bConstructed);
133 return (T*)&Bytes;
134 }
135
136private:
138 bool bConstructed;
139};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
Definition IDelegateInstance.h:112
Definition DelegateBase.h:226
@ false
Definition radaudio_common.h:23
virtual void CreateCopy(TDelegateBase< FNotThreadSafeDelegateMode > &Base) const =0
virtual void CreateCopy(TDelegateBase< FThreadSafeDelegateMode > &Base) const =0
virtual bool ExecuteIfSafe(ArgTypes...) const =0
virtual RetType Execute(ArgTypes...) const =0
virtual void CreateCopy(TDelegateBase< FNotThreadSafeNotCheckedDelegateMode > &Base) const =0
Definition DelegateInstanceInterface.h:12
Definition DelegateInstanceInterface.h:49
Ret & GetResult()
Definition DelegateInstanceInterface.h:80
TTuple< Types..., Ret > Values
Definition DelegateInstanceInterface.h:72
TPayload(ArgTypes &&... Args)
Definition DelegateInstanceInterface.h:75
void GetResult()
Definition DelegateInstanceInterface.h:97
TTuple< Types... > Values
Definition DelegateInstanceInterface.h:89
TPayload(ArgTypes &&... Args)
Definition DelegateInstanceInterface.h:92
Definition DelegateInstanceInterface.h:67
Definition DelegateInstanceInterface.h:104
T * operator->()
Definition DelegateInstanceInterface.h:130
T * operator()(ArgTypes &&... Args)
Definition DelegateInstanceInterface.h:122
TPlacementNewer()
Definition DelegateInstanceInterface.h:105
~TPlacementNewer()
Definition DelegateInstanceInterface.h:110
Definition Tuple.h:652
Definition TypeCompatibleBytes.h:24