You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can create ConstDelegate or UniqueDelegate, or NonMutableDelegate and others
For support the follow style:
auto GlobalDelegate = Delegate(...);
// change follow function
{
GlobalDelegate Delegate(shared ptr to object, ptr to method);
}
// case #1 - create from standart delegate
{
auto delegate = NEW_DELEGATE_NAME(GlobalDelegate);
WorkFunc(delegate);
}
// case #2 - create from ref to object and ptr to methodauto global_ptr = std::shared_ptr(...);
{
auto delegate = NEW_DELEGATE_NAME(*global_ptr, &decltype(*global_ptr)::FOO);
WorkFunc(delegate);
}
// case #3 - create from ref to object and ptr to methodauto global_ptr = std::shared_ptr(...);
{
Object object = ...;
auto delegate = NEW_DELEGATE_NAME(object, &Object::FOO);
WorkFunc(delegate);
}
// case #4 - create from unique_ptr to object and ptr to methodauto global_ptr = std::shared_ptr(...);
{
auto object = std::unique_ptr(...);
auto delegate = NEW_DELEGATE_NAME(object, &decltype(*object)::FOO);
WorkFunc(delegate);
}
The main purpose of such a delegate is to avoid creating a std::shared_ptr.
Since it can use only objects from its own visibility zone or from a higher one, there will be no problems with dangling pointers
P.S. also can use Platform::Delegates::Delegate template specialization
The text was updated successfully, but these errors were encountered:
We can create
ConstDelegate
orUniqueDelegate
, orNonMutableDelegate
and othersFor support the follow style:
The main purpose of such a delegate is to avoid creating a
std::shared_ptr
.Since it can use only objects from its own visibility zone or from a higher one, there will be no problems with dangling pointers
P.S. also can use
Platform::Delegates::Delegate
template specializationThe text was updated successfully, but these errors were encountered: