From: Mikko Rasa Date: Mon, 18 May 2020 23:27:15 +0000 (+0300) Subject: Add a refcount function to RefPtr X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cc541830f00cc3238edb82ff2e14e8b9060645b6;p=libs%2Fcore.git Add a refcount function to RefPtr Sometimes it may be useful to check if there are any other users for the data. --- 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); }