MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Traits.h
Go to the documentation of this file.
1/** @noop License Comment
2 * @file
3 * @copyright
4 * This Source Code is subject to the terms of the Mozilla Public License, v2.0.
5 * If a copy of the MPL was not distributed with this file You can obtain one at
6 * https://mozilla.org/MPL/2.0/
7 *
8 * @author David Mórász
9 * @date 2025
10 */
11
12#pragma once
13
14#include "CoreMinimal.h"
15#include "Mcro/FunctionTraits.h"
16#include "Mcro/Void.h"
17
18namespace Mcro::Delegates
19{
20 using namespace Mcro::FunctionTraits;
21
22 /** Constraint given type to a dynamic delegate class */
23 template <typename T>
25 requires() { typename std::decay_t<T>::ThreadSafetyMode; }
26 && CDerivedFrom<std::decay_t<T>, TScriptDelegate<typename std::decay_t<T>::ThreadSafetyMode>>
27 ;
28
29 /** Constraint given type to a dynamic multicast delegate class */
30 template <typename T>
32 requires() { typename std::decay_t<T>::ThreadSafetyMode; }
33 && CDerivedFrom<std::decay_t<T>, TMulticastScriptDelegate<typename std::decay_t<T>::ThreadSafetyMode>>
34 ;
35
36 template <typename>
38
39 /** Get the native function pointer type compatible with given dynamic delegate */
40 template <CDynamicDelegate Dynamic>
41 struct TDynamicMethodPtr_Struct<Dynamic>
42 {
43 using Type = typename Dynamic::template TMethodPtrResolver<FDeclareOnly>::FMethodPtr;
44 };
45
46 /** Get the native function pointer type compatible with given dynamic multicast delegate */
47 template <CDynamicMulticastDelegate Dynamic>
52
53 /** Get the native function pointer type compatible with given dynamic (multicast) delegate */
54 template <typename Dynamic>
56
57 template <typename>
59
60 /** Get the native function signature type compatible with given dynamic delegate */
61 template <CDynamicDelegate Dynamic>
62 struct TDynamicSignature_Struct<Dynamic>
63 {
65 };
66
67 /** Get the native function signature type compatible with given dynamic multicast delegate */
68 template <CDynamicMulticastDelegate Dynamic>
73
74 /** Get the native function signature type compatible with given dynamic (multicast) delegate */
75 template <typename Dynamic>
77
78 template <typename>
79 struct TNative_Struct {};
80
81 /** Map the input dynamic delegate to a conceptually compatible native delegate type */
82 template <CDynamicDelegate Dynamic>
83 struct TNative_Struct<Dynamic>
84 {
85 using Type = TDelegate<TDynamicSignature<Dynamic>, FDefaultDelegateUserPolicy>;
86 };
87
88 /** Map the input dynamic multicast delegate to a conceptually compatible native multicast delegate type */
89 template <CDynamicMulticastDelegate Dynamic>
90 struct TNative_Struct<Dynamic>
91 {
92 using Type = TMulticastDelegate<TDynamicSignature<Dynamic>, FDefaultDelegateUserPolicy>;
93 };
94
95 /** Map the input dynamic (multicast) delegate to a conceptually compatible native (multicast) delegate type */
96 template<typename Dynamic>
98}
typename TNative_Struct< std::decay_t< Dynamic > >::Type TNative
Definition Traits.h:97
typename TDynamicSignature_Struct< std::decay_t< Dynamic > >::Type TDynamicSignature
Definition Traits.h:76
typename TDynamicMethodPtr_Struct< std::decay_t< Dynamic > >::Type TDynamicMethodPtr
Definition Traits.h:55
typename TFunctionTraits< std::decay_t< T > >::Signature TFunction_Signature
typename Dynamic::template TMethodPtrResolver< FDeclareOnly >::FMethodPtr Type
Definition Traits.h:43
TFunction_Signature< TDynamicMethodPtr< Dynamic > > Type
Definition Traits.h:64
TDelegate< TDynamicSignature< Dynamic >, FDefaultDelegateUserPolicy > Type
Definition Traits.h:85