Get QSharedPointer's Reference Count
General and Desktop
3
Posts
2
Posters
3.7k
Views
2
Watching
-
wrote on 22 Oct 2012, 07:16 last edited by
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?
-
wrote on 22 Oct 2012, 07:48 last edited by
You could reimplement your own reference counting mechanism around "QAtomicInt":http://qt-project.org/doc/qt-4.8/qatomicint.html.
-
wrote on 22 Oct 2012, 08:14 last edited by
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?
1/3