[Development] Making QScopedPointer scoped (again)

Dmitry Ashkadov dmitry.ashkadov at gmail.com
Wed Sep 4 13:05:27 CEST 2013


Hello!

03.09.2013 15:33, Stephen Kelly ?????:
> On Tuesday, September 03, 2013 12:48:51 Daniel Teske wrote:
>
>> *const* unique_ptr is a scoped ptr. So QScopedPointer is a NIH irregardless
>> of a move support.
First of all, I think, you should define what is a 'scoped'.

> A const unique_ptr is like a Qt 5.1 QScopedPointer.
const unique_ptr never allows changes of contained raw pointer, but 
QScopedPointer allows through reset() and swap(). Did you mean const 
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.
I think QScopedPointer (depending on what is a 'scoped') should be 
movable or it should not contain swap and reset at least.

swap() allows moving QScopedPointer:

void f(QScopedPointer &p) {
     QScopedPointer x(...);
     ...
     p.swap(x);
}

without swap() and reset() that isn't possible. So, QScopedPointer 
already allows moving outside of scope and should have move-semantic.



>
> 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,
>
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130904/bf71531b/attachment.html>


More information about the Development mailing list