On 04.09.2013 07:36, Olivier Goffart wrote: > On Tuesday 03 September 2013 21:20:20 Peter Kümmel wrote: >> It is of great benefit that you never had to think about if >> QScopedPointer(5.1) will delete when leaving scope. > > That's not true. > > QScopedPointer<...> myPtr(foo()); > myPtr.take();
Sure, but then you don't pass a QScopedPointer and have to care about the plain pointer. > > And it does not delete when leaving the scope. > > Think of qMove(myPtr) of a safer convenience to the already existing take() > >> The main point is that in Qt is nothing like std::unique_ptr, > > False again. only when QScopedPointer is movable QScopedPointer is almost exactly the same as unique_ptr. They > have the same API. > Compare http://en.cppreference.com/w/cpp/memory/unique_ptr and > http://qt-project.org/doc/qt-5.0/qtcore/qscopedpointer.html and tell me again > they are > nothing like eachother. The point of the thread is not functionality but naming. > > The documentation of unique_ptr even starts with: "std::unique_ptr is a smart > pointer that retains sole ownership of an object through a pointer and > destroys that object when the unique_ptr goes out of scope." > > It is unfortunate that the standard did not choose the name > std::scoped_pointer, but that's not the first time the standard and Qt are > using different name (QByteArray <> std::string, QLinkedList <> std::list, > ...) > > (I assume you meant s/Qt/QScopedPointer/) > >> so when it is needed and we can't use std::unique_ptr, we have to introduce >> a QUniquePointer. This is better than to add features to classes which are >> contradictorily to their naming. > > Based on all the false assumptions in your mail, I think it's safe to discard > your conclusion. > Maybe boost is also some sort of reference; there the scoped pointer is also not movable: http://www.boost.org/doc/libs/1_54_0/libs/smart_ptr/scoped_ptr.htm With making QScopedPointer movable we cemented the bad naming. Peter _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
