X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fbase.h;h=0a4456f3a7fd398c2aea015b38dc88c76a5d5ded;hb=2653fbaa28c9b7b41e03abd4893ea623a6276d21;hp=45c60802c7454f85c46d5af7aeead636710cac2d;hpb=fcacc8e0306382bc3f938073092c3729d77e2b41;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/base.h b/include/base.h index 45c60802c..0a4456f3a 100644 --- a/include/base.h +++ b/include/base.h @@ -26,6 +26,7 @@ #include #include #include +#include /** Dummy class to help enforce culls being parent-called up to classbase */ class CullResult @@ -121,7 +122,7 @@ class CoreExport usecountbase }; template -class CoreExport reference +class reference { T* value; public: @@ -142,7 +143,22 @@ class CoreExport reference if (value && value->refcount_dec()) delete value; } - inline operator bool() const { return value; } + + inline reference& operator=(T* other) + { + if (value != other) + { + if (value && value->refcount_dec()) + delete value; + value = other; + if (value) + value->refcount_inc(); + } + + return *this; + } + + inline operator bool() const { return (value != NULL); } inline operator T*() const { return value; } inline T* operator->() const { return value; } inline T& operator*() const { return *value; } @@ -150,7 +166,7 @@ class CoreExport reference inline bool operator>(const reference& other) const { return value > other.value; } static inline void* operator new(size_t, void* m) { return m; } private: -#ifndef WIN32 +#ifndef _WIN32 static void* operator new(size_t); static void operator delete(void*); #endif