3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-04 13:21:22 +00:00

move semantics for ref

This commit is contained in:
Arie Gurfinkel 2017-07-31 14:21:30 -04:00
parent 331eec8a05
commit 1d5713c376

View file

@ -50,6 +50,7 @@ public:
inc_ref(); inc_ref();
} }
ref (ref && r): m_ptr (r.detach ()) {}
~ref() { ~ref() {
dec_ref(); dec_ref();
} }
@ -89,6 +90,14 @@ public:
return *this; return *this;
} }
ref & operator=(ref &&r) {
if (this != &r) {
dec_ref ();
m_ptr = r.detach ();
}
return *this;
}
void reset() { void reset() {
dec_ref(); dec_ref();
m_ptr = 0; m_ptr = 0;
@ -107,6 +116,11 @@ public:
friend bool operator!=(const ref & r1, const ref & r2) { friend bool operator!=(const ref & r1, const ref & r2) {
return r1.m_ptr != r2.m_ptr; return r1.m_ptr != r2.m_ptr;
} }
friend void swap (ref &r1, ref &r2) {
T* tmp = r1.m_ptr;
r1.m_ptr = r2.m_ptr;
r2.m_ptr = tmp;
}
}; };
/** /**