mirror of
https://github.com/Z3Prover/z3
synced 2025-04-08 10:25:18 +00:00
move semantics for ref
This commit is contained in:
parent
331eec8a05
commit
1d5713c376
|
@ -50,6 +50,7 @@ public:
|
|||
inc_ref();
|
||||
}
|
||||
|
||||
ref (ref && r): m_ptr (r.detach ()) {}
|
||||
~ref() {
|
||||
dec_ref();
|
||||
}
|
||||
|
@ -89,6 +90,14 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
ref & operator=(ref &&r) {
|
||||
if (this != &r) {
|
||||
dec_ref ();
|
||||
m_ptr = r.detach ();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
dec_ref();
|
||||
m_ptr = 0;
|
||||
|
@ -107,6 +116,11 @@ public:
|
|||
friend bool operator!=(const ref & r1, const ref & r2) {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue