X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/664e13143ee51a6b1aa1c30d1401ac04b11bdcca..66f2aa61c3c7bc326f3287739eded70ca61f775d:/include/wx/scopedptr.h diff --git a/include/wx/scopedptr.h b/include/wx/scopedptr.h index a27b8dbd6b..f31a4ef036 100644 --- a/include/wx/scopedptr.h +++ b/include/wx/scopedptr.h @@ -43,11 +43,17 @@ public: wxEXPLICIT wxScopedPtr(T * ptr = NULL) : m_ptr(ptr) { } - ~wxScopedPtr() { delete m_ptr; } + ~wxScopedPtr() { wxCHECKED_DELETE(m_ptr); } // test for pointer validity: defining conversion to unspecified_bool_type // and not more obvious bool to avoid implicit conversions to integer types +#ifdef __BORLANDC__ + // this compiler is too dumb to use unspecified_bool_type operator in tests + // of the form "if ( !ptr )" + typedef bool unspecified_bool_type; +#else typedef T *(wxScopedPtr::*unspecified_bool_type)() const; +#endif // __BORLANDC__ operator unspecified_bool_type() const { return m_ptr ? &wxScopedPtr::get : NULL; @@ -57,7 +63,7 @@ public: { if ( ptr != m_ptr ) { - delete m_ptr; + wxCHECKED_DELETE(m_ptr); m_ptr = ptr; } } @@ -123,14 +129,7 @@ public: \ \ ~name(); \ \ - void reset(T * ptr = NULL) \ - { \ - if (m_ptr != ptr) \ - { \ - delete m_ptr; \ - m_ptr = ptr; \ - } \ - } \ + void reset(T * ptr = NULL); \ \ T *release() \ { \ @@ -165,6 +164,14 @@ public: \ }; #define wxDEFINE_SCOPED_PTR(T, name)\ +void name::reset(T * ptr) \ +{ \ + if (m_ptr != ptr) \ + { \ + wxCHECKED_DELETE(m_ptr); \ + m_ptr = ptr; \ + } \ +} \ name::~name() \ { \ wxCHECKED_DELETE(m_ptr); \