mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +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
|
@ -32,9 +32,19 @@ 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 (this != &r)
|
||||
{
|
||||
if (ptr) ptr->DecRef();
|
||||
ptr = r.ptr;
|
||||
r.ptr = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue