]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/defs.h
define wxString::iterator::iterator_category correctly if wxUSE_STD_STRING and not...
[wxWidgets.git] / include / wx / defs.h
index 36be2abf2fd3e5d8f0b94ca8165eb2d375922718..9ed2232e6aaec25c8e14dd1c238f3981cdba10db 100644 (file)
@@ -611,15 +611,33 @@ typedef short int WXTYPE;
 #include <stddef.h>
 #endif
 
-/*  delete pointer if it is not NULL and NULL it afterwards */
-/*  (checking that it's !NULL before passing it to delete is just a */
-/*   a question of style, because delete will do it itself anyhow, but it might */
-/*   be considered as an error by some overzealous debugging implementations of */
-/*   the library, so we do it ourselves) */
-#define wxDELETE(p)      if ( (p) != NULL ) { delete p; p = NULL; }
+#ifdef __cplusplus
+    // delete pointer if it is not NULL and NULL it afterwards
+    template <typename T>
+    inline void wxDELETE(T*& ptr)
+    {
+        typedef char TypeIsCompleteCheck[sizeof(T)];
+
+        if ( ptr != NULL )
+        {
+            delete ptr;
+            ptr = NULL;
+        }
+    }
+
+    // delete an array and NULL it (see comments above)
+    template <typename T>
+    inline void wxDELETEA(T*& ptr)
+    {
+        typedef char TypeIsCompleteCheck[sizeof(T)];
 
-/*  delete an array and NULL it (see comments above) */
-#define wxDELETEA(p)     if ( (p) ) { delete [] (p); p = NULL; }
+        if ( ptr != NULL )
+        {
+            delete [] ptr;
+            ptr = NULL;
+        }
+    }
+#endif /*__cplusplus*/
 
 /*  size of statically declared array */
 #define WXSIZEOF(array)   (sizeof(array)/sizeof(array[0]))
@@ -1101,19 +1119,21 @@ typedef wxUint32 wxDword;
 #endif
 
 
-/* Make sure ssize_t is defined (a signed type the same size as size_t) */
-/* HAVE_SSIZE_T should be defined for compiliers that already have it */
+/* Make sure ssize_t is defined (a signed type the same size as size_t). */
+/* (HAVE_SSIZE_T is not already defined by configure) */
+#ifndef HAVE_SSIZE_T
 #ifdef __MINGW32__
-    #if defined(_SSIZE_T_) && !defined(HAVE_SSIZE_T)
+    #if defined(_SSIZE_T_) || defined(_SSIZE_T_DEFINED)
         #define HAVE_SSIZE_T
     #endif
-#endif
-#if defined(__PALMOS__) && !defined(HAVE_SSIZE_T)
+#elif defined(__PALMOS__)
     #define HAVE_SSIZE_T
-#endif
-#if wxCHECK_WATCOM_VERSION(1,4)
+#elif wxCHECK_WATCOM_VERSION(1,4)
     #define HAVE_SSIZE_T
 #endif
+#endif /* !HAVE_SSIZE_T */
+
+/* If we really don't have ssize_t, provide our own version. */
 #ifdef HAVE_SSIZE_T
     #ifdef __UNIX__
         #include <sys/types.h>
@@ -3185,6 +3205,11 @@ typedef const void* WXWidget;
         classname(const classname&);            \
         classname& operator=(const classname&);
 
+#define DECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg)  \
+    private:                                            \
+        classname(const classname<arg>&);               \
+        classname& operator=(const classname<arg>&);
+
 #define DECLARE_NO_ASSIGN_CLASS(classname)      \
     private:                                    \
         classname& operator=(const classname&);