[Development] Making QScopedPointer scoped (again)

Stephen Kelly stephen.kelly at kdab.com
Tue Sep 3 13:33:48 CEST 2013


On Tuesday, September 03, 2013 12:48:51 Daniel Teske wrote:
> > Again, this is what std::unique_ptr is for. We should not try to turn
> > QScopedPointer into an attempt at a NIH std::unique_ptr. Where people have
> > a need for a std::unique_ptr, they should use it. We should not adapt
> > QScopedPointer to fit the need instead.
> > 
> > Adding a move contructor to QScopedPointer makes no sense, because moving
> > means 'escaping the scope', which breaks the fundamental point of
> > QScopedPointer. QScopedPointer is different to std::unique_ptr and should
> > remain so.
> 
> *const* unique_ptr is a scoped ptr. So QScopedPointer is a NIH irregardless
> of a move support.

A const unique_ptr is like a Qt 5.1 QScopedPointer. 
A const unique_ptr can not be moved. 
A const unique_ptr is *not* like a Qt 5.2 QScopedPointer. 
A Qt 5.2 QScopedPointer can be moved. 
That is why we have this thread. I am suggesting that a Qt 5.2 QScopedPointer 
should not be movable.

Your point is also C++11 only. QScopedPointer also works with C++98.

So QScopedPointer still has a reason to exist, and it still has no reason to 
be movable.

Thanks,

-- 
Join us in October at Qt Developer Days 2013 - https://devdays.kdab.com

Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130903/c691a48e/attachment.sig>


More information about the Development mailing list