-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
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 method
auto 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 method
auto 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 method
auto 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
konard
Metadata
Metadata
Assignees
Labels
No labels