first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,78 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NAUTO_PTR__
#define __NAUTO_PTR__
#include "alloc/ialloc.h"
#include "billing/billing.h"
namespace GS {
/*!
@short Auto pointer.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
template <class T> class AutoPtr
{
private:
T *o;
public:
inline operator T*() const
{ return o; }
inline T *c_ptr() const
{ return o; }
inline bool IsNull() const { return o ? false : true; }
inline bool IsValid() const { return o ? true : false; }
T *operator = (T *p)
{
if (o != p)
{
delete(o);
o = p;
}
return o;
}
inline T &operator[] (size_t n) { return o[n]; }
inline bool operator == (const T *p) const
{ return o == p; }
inline bool operator != (const T *p) const
{ return o != p; }
inline T *operator -> () const
{ return o; }
inline T &operator * () const
{ return *o; }
inline T *Detach()
{
T *p = o;
o = 0;
return p;
}
explicit AutoPtr(T *p = 0) : o(p)
{}
~AutoPtr()
{
delete(o);
o = 0;
}
};
} // GS
#endif // __NAUTO_PTR__