Add move constructor and move assignment operator
This commit is contained in:
1 parent
2e30a9f407
commit
62b729badd
2 files changed
+71
No files matched your search
@@ -70,6 +70,25 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
rcp(rcp && other) noexcept : ptr(other.ptr)
|
||||
{
|
||||
other.ptr = nullptr;
|
||||
}
|
||||
|
||||
rcp<T> & operator=(rcp && other) noexcept
|
||||
{
|
||||
if (ptr != other.ptr)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
ptr->rcp_dec();
|
||||
}
|
||||
ptr = other.ptr;
|
||||
other.ptr = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
~rcp()
|
||||
{
|
||||
if (ptr)
|
||||
|
||||
Reference in new issue
Block a user