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::Detail |
Typedefs | |
template<CFunctionLike Function, typename... Captures> | |
using | Mcro::Delegates::TInferredDelegate |
Functions | |
template<CFunctionLike Function, typename... Captures> requires (!TFunction_IsMember<Function>) && (!CFunctorObject<Function>) | |
TInferredDelegate< Function, Captures... > | Mcro::Delegates::From (Function func, const Captures &... captures) |
template<CFunctorObject Function> | |
TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::From (Function &&func) |
template<CSharedRef Object, CFunctorObject Function> | |
TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::From (const Object &self, Function &&func) |
template<CSharedFromThis Object, CFunctorObject Function> | |
TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::From (Object *self, Function &&func) |
template<CSharedFromThis Object, CFunctorObject Function> | |
TDelegate< TFunction_Signature< Function > > | Mcro::Delegates::From (const Object *self, Function &&func) |
template<CPlainClass Object, CFunctionLike Function, typename... Captures> requires TFunction_IsMember<Function> && (!CFunctorObject<Function>) | |
TInferredDelegate< Function, Captures... > | Mcro::Delegates::From (Object *self, Function func, const Captures &... captures) |
template<CPlainClass Object, CFunctionLike Function, typename... Captures> requires TFunction_IsMember<Function> && (!CFunctorObject<Function>) | |
TInferredDelegate< Function, Captures... > | Mcro::Delegates::From (const Object *self, Function func, const Captures &... captures) |
template<CSharedRef Object, CFunctionLike Function, typename... Captures> requires TFunction_IsMember<Function> && (!CFunctorObject<Function>) | |
TInferredDelegate< Function, Captures... > | Mcro::Delegates::From (const Object &self, Function func, const Captures &... captures) |
template<typename... Args> | |
TDelegate< void(Args...)> | Mcro::Delegates::From (TMulticastDelegate< void(Args...)> &multicast) |
template<typename Object , typename... Args> | |
TDelegate< void(Args...)> | Mcro::Delegates::From (Object &&self, TMulticastDelegate< void(Args...)> &multicast) |
template<CDynamicMulticastDelegate Dynamic, size_t... ArgIndices> | |
TNative< typename Dynamic::FDelegate > | Mcro::Delegates::Detail::FromDynamicMulticastDelegate (Dynamic &multicast, std::index_sequence< ArgIndices... > &&) |
template<typename Object , CDynamicMulticastDelegate Dynamic, size_t... ArgIndices> | |
TNative< typename Dynamic::FDelegate > | Mcro::Delegates::Detail::FromDynamicMulticastDelegate (Object &&self, Dynamic &multicast, std::index_sequence< ArgIndices... > &&) |
template<CDynamicMulticastDelegate Dynamic> | |
TNative< typename Dynamic::FDelegate > | Mcro::Delegates::From (Dynamic &multicast) |
template<typename Object , CDynamicMulticastDelegate Dynamic> | |
TNative< typename Dynamic::FDelegate > | Mcro::Delegates::From (Object &&self, Dynamic &multicast) |
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. Mcro::Delegate::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.