PDA

View Full Version : QSharedPointer of type void



HERC
12th May 2010, 13:59
Hello,

In boost we have shared_ptr for working with smart pointers, in boost it is possible to define a smart pointer of type void :

Using shared_ptr<void> to hold an arbitrary object

shared_ptr<void> can act as a generic object pointer similar to void*. When a shared_ptr<void> instance constructed as:

shared_ptr<void> pv(new X);
is destroyed, it will correctly dispose of the X object by executing ~X.

This propery can be used in much the same manner as a raw void* is used to temporarily strip type information from an object pointer. A shared_ptr<void> can later be cast back to the correct type by using static_pointer_cast.


In Qt is not possible to define a QSharedPointer of type void. Does someone know if there exist a way to this in QT or do I have to use the boost libraries with qt?