[bt-devel] Using QSharedPointer instead of boost pointer

Eeli Kaikkonen eekaikko at mail.student.oulu.fi
Thu Apr 23 08:40:31 MST 2009


ATM the only thing we use the boost library for is the scoped pointer. 
Qt 4.5 offers QSharedPointer. The documentation says:

"QSharedPointer::~QSharedPointer ()
Destroys this QSharedPointer object. If it is the last reference to the 
pointer stored, this will delete the pointer as well."

And:

"The QSharedPointer is an automatic, shared pointer in C++. It behaves 
exactly like a normal pointer for normal purposes, including respect for 
constness.

QSharedPointer will delete the pointer it is holding when it goes out of 
scope, provided no other QSharedPointer objects are referencing it."

It looks like we could use this instead of the boost::scoped_ptr. At 
least for Windows it would make things easier by reducing dependencies. 
But it requires Qt 4.5 - 4.4 is not enough. This could be done also with 
#ifdefs, depending on the Qt version, so that if Qt >= 4.5 boost is not 
needed.

Martin, you have used the scoped_ptr more. What do you think?

--Eeli Kaikkonen



More information about the bt-devel mailing list