4 // disable the operator -> on UDT warning
7 #pragma warning(disable : 4284)
10 #include "NoWindows.h"
12 /*************************************************************************************************
13 CSmartPtr - a simple smart pointer class that can automatically initialize and free memory
14 note: (doesn't do garbage collection / reference counting because of the many pitfalls)
15 *************************************************************************************************/
16 template <class TYPE
> class CSmartPtr
28 CSmartPtr(TYPE
* a_pObject
, BOOL a_bArray
= FALSE
, BOOL a_bDelete
= TRUE
)
32 Assign(a_pObject
, a_bArray
, a_bDelete
);
40 void Assign(TYPE
* a_pObject
, BOOL a_bArray
= FALSE
, BOOL a_bDelete
= TRUE
)
44 m_bDelete
= a_bDelete
;
46 m_pObject
= a_pObject
;
51 if (m_bDelete
&& m_pObject
)
62 void SetDelete(const BOOL a_bDelete
)
64 m_bDelete
= a_bDelete
;
67 __inline TYPE
* GetPtr() const
72 __inline
operator TYPE
* () const
77 __inline TYPE
* operator ->() const
82 // declare assignment, but don't implement (compiler error if we try to use)
83 // that way we can't carelessly mix smart pointers and regular pointers
84 __inline
void * operator =(void *) const;
91 #endif // #ifndef APE_SMARTPTR_H