Get QSharedPointer's Reference Count
-
Is there any way I can retrieve the reference count for a QSharedPointer? If not what is the best way (if any) to implement a subclass of QSharedPointer that can return the reference count?
-
You could reimplement your own reference counting mechanism around "QAtomicInt":http://qt-project.org/doc/qt-4.8/qatomicint.html.
-
Wow, cool. I was just implmeneting my own atomic int. Didn't know there was a class in Qt.
So should I inherit from QSharedPointer and in every constructor and copy constructor increase the count; and then decrease the count in the desctructor?