]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/scopedptr.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / scopedptr.h
index a27b8dbd6b703c8093197d4200518ba5ff7a9fc7..5cc0c0770d5fa8b79b1b323f6747e63bcdd5106f 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     scoped smart pointer class
 // Author:      Jesse Lovelace <jllovela@eos.ncsu.edu>
 // Created:     06/01/02
-// RCS-ID:      $Id$
 // Copyright:   (c) Jesse Lovelace and original Boost authors (see below)
 //              (c) 2009 Vadim Zeitlin
 // Licence:     wxWindows licence
@@ -43,11 +42,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<T>::*unspecified_bool_type)() const;
+#endif // __BORLANDC__
     operator unspecified_bool_type() const
     {
         return m_ptr ? &wxScopedPtr<T>::get : NULL;
@@ -57,7 +62,7 @@ public:
     {
         if ( ptr != m_ptr )
         {
-            delete m_ptr;
+            wxCHECKED_DELETE(m_ptr);
             m_ptr = ptr;
         }
     }
@@ -123,14 +128,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 +163,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);        \