They both do basically the same thing. The Qt version seems to have the ability to abscond with the pointer (QScopedPointer::take()
), which allows you to transfer ownership to someone else. You can't do that with scoped_ptr
, but you can swap both kinds.
boost::scoped_ptr
and QScopedPointer
are also is explicitly non-copyable.
QScopedPointer
does have a mechanism that allows you to pass a "deleter" to the pointer. This is effectively a public static member of the given class, so QScopedPointer
is still only the size of a pointer. It does mean that the type of QScopedPointer
must include the deleter's type.
Both of them are made obsolete by std::unqiue_ptr
in C++0x.