summaryrefslogtreecommitdiff
path: root/binaryninjaapi.h
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2019-08-02 12:04:19 -0400
committerPeter LaFosse <peter@vector35.com>2019-08-03 10:29:38 -0400
commitee72f8df7139a0bb960d289a81c65641882d0db2 (patch)
tree6550c5e4878913a399ad6981fecc89a3f1c6b4e0 /binaryninjaapi.h
parentd211df96cc9d27922e79137307cb3243c28e8157 (diff)
Add move constructors to Ref objects
Diffstat (limited to 'binaryninjaapi.h')
-rw-r--r--binaryninjaapi.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index e4af4672..29f7c3b1 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -241,6 +241,14 @@ namespace BinaryNinja
}
}
+ Ref<T>(Ref<T>&& other) : m_obj(other.m_obj)
+ {
+ other.m_obj = 0;
+#ifdef BN_REF_COUNT_DEBUG
+ m_assignmentTrace = other.m_assignmentTrace;
+#endif
+ }
+
~Ref<T>()
{
if (m_obj)
@@ -269,6 +277,22 @@ namespace BinaryNinja
return *this;
}
+ Ref<T>& operator=(Ref<T>&& other)
+ {
+ if (this != &other)
+ {
+ if (!m_obj)
+ m_obj = other.m_obj;
+ else if (m_obj != other.m_obj)
+ {
+ m_obj->Release();
+ m_obj = other.m_obj;
+ }
+ other.m_obj = 0;
+ }
+ return *this;
+ }
+
Ref<T>& operator=(T* obj)
{
#ifdef BN_REF_COUNT_DEBUG