From 187fe67ffaa75ede52a9caf0061d2a5ae350e81e Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 14 Nov 2017 17:13:29 -0600 Subject: [PATCH] fixup debugPtr --- src/misc/debugPtr.cpp | 2 ++ src/misc/pv/debugPtr.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/misc/debugPtr.cpp b/src/misc/debugPtr.cpp index c8c3a91..62146e0 100644 --- a/src/misc/debugPtr.cpp +++ b/src/misc/debugPtr.cpp @@ -18,6 +18,8 @@ typedef epicsGuard Guard; namespace epics { namespace debug { +// joins together a group of ptr_base instances +// which all have the same dtor struct tracker { epicsMutex mutex; ptr_base::ref_set_t refs; diff --git a/src/misc/pv/debugPtr.h b/src/misc/pv/debugPtr.h index 40e3db6..479eafc 100644 --- a/src/misc/pv/debugPtr.h +++ b/src/misc/pv/debugPtr.h @@ -54,11 +54,13 @@ public: void show_refs(std::ostream&, bool self=true, bool weak=false) const; void spy_refs(ref_set_t&) const; }; + class epicsShareClass weak_ptr_base : public ptr_base { protected: weak_ptr_base() {} weak_ptr_base(const track_t& track) :ptr_base(track) {} }; + class epicsShareClass shared_ptr_base : public ptr_base { protected: shared_ptr_base() noexcept @@ -149,6 +151,10 @@ public: template shared_ptr(const weak_ptr& o) :shared_ptr_base(o.track), real(o.real) {track_new();} + // takeover from unique_ptr + template + shared_ptr(std::unique_ptr&& a) : shared_ptr_base(), real(a.release()) {track_new();} + ~shared_ptr() {} shared_ptr& operator=(const shared_ptr& o) {