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

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Wed Apr 19 16:52:22 CEST 2017


Il 19/04/2017 15:44, Konstantin Tokarev ha scritto:
> 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?

Where to place it: in qobject.h, unless we claim this is done for STL
compatibility, and therefore it may need to go somewhere else depending
on the resolution on the other thread.

I don't think this stuff should be there purely for STL compatibility.
In hindsight, the QScopedPointer deleters should have had more generic
names than QScopedPointerFoo, as they should be usable in other
scenarios too (QSharedPointer?).

So, maybe, just add this as an inner class of QObject?
QObject::DeleteLater(Functor) maybe?

My 2 cents,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170419/c5e866d3/attachment.bin>


More information about the Development mailing list