mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 21:41:03 +00:00
- made RefCountedPtr follow rule of five
This commit is contained in:
parent
67e7d1a6f5
commit
bbcd522052
1 changed files with 19 additions and 6 deletions
|
@ -31,10 +31,20 @@ public:
|
|||
{
|
||||
if (ptr) ptr->IncRef();
|
||||
}
|
||||
|
||||
|
||||
RefCountedPtr(const RefCountedPtr& r) : ptr(r.ptr)
|
||||
{
|
||||
if (ptr) ptr->IncRef();
|
||||
}
|
||||
|
||||
RefCountedPtr(RefCountedPtr&& r) : ptr(r.ptr)
|
||||
{
|
||||
r.ptr = nullptr;
|
||||
}
|
||||
|
||||
RefCountedPtr & operator=(const RefCountedPtr& r)
|
||||
{
|
||||
if (ptr != r.ptr)
|
||||
if (this != &r)
|
||||
{
|
||||
if (ptr) ptr->DecRef();
|
||||
ptr = r.ptr;
|
||||
|
@ -54,11 +64,14 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
RefCountedPtr & operator=(const RefCountedPtr&& r)
|
||||
RefCountedPtr & operator=(RefCountedPtr&& r)
|
||||
{
|
||||
if (ptr) ptr->DecRef();
|
||||
ptr = r.ptr;
|
||||
r.ptr = nullptr;
|
||||
if (this != &r)
|
||||
{
|
||||
if (ptr) ptr->DecRef();
|
||||
ptr = r.ptr;
|
||||
r.ptr = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue