[Development] Making QScopedPointer scoped (again)

Stephen Kelly stephen.kelly at kdab.com
Tue Sep 3 11:10:38 CEST 2013


On Tuesday, September 03, 2013 10:41:35 Giuseppe D'Angelo wrote:
> While I partially agree with the dreaded NIH syndrome, let me forward
> the argument that "escaping the scope" is very explicit in the code:

If it shouldn't be possible, it doesn't matter how explicit it is.

> The move assignment in particular doesn't require anything "new" -- it's
> literally q.reset(p.take()).

The first point in my mail was that if you are doing q.reset(p.take()), then 
you don't want QScopedPointer in the first place. You want std::unique_ptr 
instead. 

If you don't have c++11, then you would have to stick with q.reset(p.take()) 
anyway (and you should reconsider why you are using QScopedPointer there at 
all, if this is existing code).

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/5ff5abb5/attachment.sig>


More information about the Development mailing list