[Development] Deleter that calls deleteLater() for use with std::unique_ptr<> and other smart pointers

Konstantin Tokarev annulen at yandex.ru
Wed Apr 19 20:46:48 CEST 2017



19.04.2017, 21:37, "Darin Broady" <dbroady1 at yahoo.com>:
> Is there a reason a new member function for QScopedPointerObjectDeleteLater that conforms to the interface specified by std::default_delete would not work?
>
>    void QScopedPointerObjectDeleteLater::operator()(T *pointer) const { if (pointer) pointer->deleteLater(); }

No strong reason, this was one of my thoughts too. 
One minor thing is that it won't have anything to do with QScopedPointer.

>
> Darin Broady
> dbroady1 at yahoo.com
>
> On Wednesday, April 19, 2017 9:44 AM, Konstantin Tokarev <annulen at yandex.ru> wrote:
>
> Hello,
>
> I think it will be a good idea to provide implementation of functor calling
> deleteLater() instead of delete which can be used with std::unique_ptr,
> std::shared_ptr and other smart pointers with compatible interface.
>
> We already have QScopedPointerObjectDeleteLater, however it implements
> cleanup(T*) instead of operator()(T*).
>
> Any suggestions how to name this new class and where to place it?
>
> --
> Regards,
> Konstantin
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development


-- 
Regards,
Konstantin



More information about the Development mailing list