summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils.hh18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/utils.hh b/src/utils.hh
index ec2ac364..6555e320 100644
--- a/src/utils.hh
+++ b/src/utils.hh
@@ -76,10 +76,26 @@ public:
if (m_ptr)
m_ptr->inc_safe_count();
}
-
return *this;
}
+ safe_ptr& operator=(safe_ptr&& other)
+ {
+ if (m_ptr != other.m_ptr)
+ {
+ if (m_ptr)
+ m_ptr->dec_safe_count();
+ m_ptr = other.m_ptr;
+ other.m_ptr = nullptr;
+ }
+ return *this;
+ }
+
+ void reset(T* ptr)
+ {
+ *this = safe_ptr(ptr);
+ }
+
bool operator== (const safe_ptr& other) const { return m_ptr == other.m_ptr; }
bool operator!= (const safe_ptr& other) const { return m_ptr != other.m_ptr; }
bool operator== (T* ptr) const { return m_ptr == ptr; }