projects
/
libs
/
core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0f32d12
)
Add a refcount function to RefPtr
author
Mikko Rasa
<tdb@tdb.fi>
Mon, 18 May 2020 23:27:15 +0000
(
02:27
+0300)
committer
Mikko Rasa
<tdb@tdb.fi>
Mon, 18 May 2020 23:27:15 +0000
(
02:27
+0300)
Sometimes it may be useful to check if there are any other users for the
data.
source/core/refptr.h
patch
|
blob
|
history
diff --git
a/source/core/refptr.h
b/source/core/refptr.h
index d245b34a7e90bab8fb14f5e26cc691a1385f761c..0328340eb242242b29fa614d0b7b815eddcc8f3b 100644
(file)
--- a/
source/core/refptr.h
+++ b/
source/core/refptr.h
@@
-88,6
+88,8
@@
public:
T *operator->() const { return data; }
operator bool() const { return data!=0; }
+ unsigned refcount() const { return (data ? *count : 0); }
+
template<typename U>
static RefPtr<T> cast_dynamic(const RefPtr<U> &p)
{ return RefPtr<T>(dynamic_cast<T *>(p.data), p.count); }