mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Remove SharedPtr, it's not used and will be never used, we use C++11
This commit is contained in:
parent
bfacfc2062
commit
718121df91
2 changed files with 0 additions and 76 deletions
|
@ -24,80 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "../debug.h" // For assert()
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
class SharedPtr
|
||||
{
|
||||
public:
|
||||
SharedPtr(T *t=NULL)
|
||||
{
|
||||
refcount = new int;
|
||||
*refcount = 1;
|
||||
ptr = t;
|
||||
}
|
||||
SharedPtr(SharedPtr<T> &t)
|
||||
{
|
||||
//*this = t;
|
||||
drop();
|
||||
refcount = t.refcount;
|
||||
(*refcount)++;
|
||||
ptr = t.ptr;
|
||||
}
|
||||
~SharedPtr()
|
||||
{
|
||||
drop();
|
||||
}
|
||||
SharedPtr<T> & operator=(T *t)
|
||||
{
|
||||
drop();
|
||||
refcount = new int;
|
||||
*refcount = 1;
|
||||
ptr = t;
|
||||
return *this;
|
||||
}
|
||||
SharedPtr<T> & operator=(SharedPtr<T> &t)
|
||||
{
|
||||
drop();
|
||||
refcount = t.refcount;
|
||||
(*refcount)++;
|
||||
ptr = t.ptr;
|
||||
return *this;
|
||||
}
|
||||
T* operator->()
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
T & operator*()
|
||||
{
|
||||
return *ptr;
|
||||
}
|
||||
bool operator!=(T *t)
|
||||
{
|
||||
return ptr != t;
|
||||
}
|
||||
bool operator==(T *t)
|
||||
{
|
||||
return ptr == t;
|
||||
}
|
||||
T & operator[](unsigned int i)
|
||||
{
|
||||
return ptr[i];
|
||||
}
|
||||
private:
|
||||
void drop()
|
||||
{
|
||||
assert((*refcount) > 0);
|
||||
(*refcount)--;
|
||||
if(*refcount == 0)
|
||||
{
|
||||
delete refcount;
|
||||
if(ptr != NULL)
|
||||
delete ptr;
|
||||
}
|
||||
}
|
||||
T *ptr;
|
||||
int *refcount;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class Buffer
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue