From cc541830f00cc3238edb82ff2e14e8b9060645b6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 19 May 2020 02:27:15 +0300 Subject: [PATCH] Add a refcount function to RefPtr Sometimes it may be useful to check if there are any other users for the data. --- source/core/refptr.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/core/refptr.h b/source/core/refptr.h index d245b34..0328340 100644 --- 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 static RefPtr cast_dynamic(const RefPtr &p) { return RefPtr(dynamic_cast(p.data), p.count); } -- 2.45.2