![]() |
MCRO
C++23 utilities for Unreal Engine.
|
#include "CoreMinimal.h"#include "Mcro/FunctionTraits.h"#include "Mcro/Delegates/Traits.h"#include "Mcro/Tuples.h"Go to the source code of this file.
Namespaces | |
| namespace | Mcro |
| namespace | Mcro::Delegates |
| namespace | Mcro::Delegates::InferDelegate |
The extra layer of namespace InferDelegate is there for guarding common vocabulary (From) but still allowing the developer to use this namespace for a more terse syntax. | |
| namespace | Mcro::Delegates::InferDelegate::Detail |
Functions | |
| template<CFunctionPtr Function, typename... Captures> requires (!CFunction_IsMember<Function>) && (!CFunctorObject<Function>) | |
| TInferredDelegate< Function, Captures... > | Mcro::Delegates::InferDelegate::From (Function func, Captures &&... captures) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. | |
| template<CFunctorObject Function> | |
| TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::InferDelegate::From (Function &&func) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. | |
| template<CSharedRef Object, CFunctorObject Function> | |
| TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::InferDelegate::From (Object const &self, Function &&func) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<CSharedFromThis Object, CFunctorObject Function> | |
| TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::InferDelegate::From (Object *self, Function &&func) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<CSharedFromThis Object, CFunctorObject Function> | |
| TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::InferDelegate::From (const Object *self, Function &&func) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<CPlainClass Object, CFunctionPtr Function, typename... Captures> requires CFunction_IsMember<Function> | |
| TInferredDelegate< Function, Captures... > | Mcro::Delegates::InferDelegate::From (Object *self, Function func, const Captures &... captures) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<CPlainClass Object, CFunctionPtr Function, typename... Captures> requires CFunction_IsMember<Function> | |
| TInferredDelegate< Function, Captures... > | Mcro::Delegates::InferDelegate::From (const Object *self, Function func, const Captures &... captures) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<CSharedRef Object, CFunctionPtr Function, typename... Captures> requires CFunction_IsMember<Function> | |
| TInferredDelegate< Function, Captures... > | Mcro::Delegates::InferDelegate::From (const Object &self, Function func, const Captures &... captures) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<CUObject Object, CFunctionPtr Function, typename... Captures> requires CFunction_IsMember<Function> | |
| TInferredDelegate< Function, Captures... > | Mcro::Delegates::InferDelegate::From (TObjectPtr< Object > self, Function func, const Captures &... captures) |
| Instead of specifying manually a delegate type, infer it from the input function and the extra captures. Also infer the method of object binding based on the type traits of the object argument. | |
| template<typename... Args> | |
| TDelegate< void(Args...)> | Mcro::Delegates::InferDelegate::From (TMulticastDelegate< void(Args...)> &multicast) |
| Broadcast a multicast delegate when the returned delegate is executed. | |
| template<typename Object , typename... Args> | |
| TDelegate< void(Args...)> | Mcro::Delegates::InferDelegate::From (Object &&self, TMulticastDelegate< void(Args...)> &multicast) |
| Broadcast a multicast delegate when the returned delegate is executed with a binding object. | |
| template<CDynamicMulticastDelegate Dynamic, size_t... ArgIndices> | |
| TNative< typename Dynamic::FDelegate > | Mcro::Delegates::InferDelegate::Detail::FromDynamicMulticastDelegate (Dynamic &multicast, std::index_sequence< ArgIndices... > &&) |
| template<typename Object , CDynamicMulticastDelegate Dynamic, size_t... ArgIndices> | |
| TNative< typename Dynamic::FDelegate > | Mcro::Delegates::InferDelegate::Detail::FromDynamicMulticastDelegate (Object &&self, Dynamic &multicast, std::index_sequence< ArgIndices... > &&) |
| template<CDynamicMulticastDelegate Dynamic> | |
| TNative< typename Dynamic::FDelegate > | Mcro::Delegates::InferDelegate::From (Dynamic &multicast) |
| Broadcast a dynamic multicast delegate when the returned delegate is executed. | |
| template<typename Object , CDynamicMulticastDelegate Dynamic> | |
| TNative< typename Dynamic::FDelegate > | Mcro::Delegates::InferDelegate::From (Object &&self, Dynamic &multicast) |
| Broadcast a dynamic multicast delegate when the returned delegate is executed. | |
Unreal delegates while being great they have the problem that they're pretty verbose to use, as the usage site requires the developer to spell out the delegate types when they're being bound to something. InferDelegate::From overloads not only infer delegate types from input function, but they also infer how the delegate is being used. For example take From(this, &FStuff::MyFunc) can map to several classic delegate usages depending on the type of this:
this is TSharedFromThisthis is a UObjectthis is just a plain old C++ objectFrom can also deal with
From(this, &FStuff::MyFunc, TEXT_"my capture") will correctly remove the last argument from the function signature of FStuff::MyFunc when inferring the delegate type.Definition in file DelegateFrom.h.