]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed compilation for GCC 3.4 when wxUSE_STL == 1.
authorMattia Barbon <mbarbon@cpan.org>
Sun, 13 Mar 2005 17:08:43 +0000 (17:08 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Sun, 13 Mar 2005 17:08:43 +0000 (17:08 +0000)
Should be compatible with VC6.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32797 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/list.h

index 97a965b24662d4cbf8f50bce0aefbe80a6c96e56..136aeaf0f336565390ef1fcda79cfc107ea640f1 100644 (file)
@@ -98,27 +98,18 @@ enum wxKeyType
 #define WX_DECLARE_LIST_WITH_DECL(elT, liT, decl) \
     WX_DECLARE_LIST_XO(elT*, liT, decl)
 
+template<class T>
+class WXDLLIMPEXP_BASE wxList_SortFunction
+{
+public:
+    wxList_SortFunction(wxSortCompareFunction f) : m_f(f) { }
+    bool operator()(const T& i1, const T& i2)
+      { return m_f((T*)&i1, (T*)&i2) < 0; }
+private:
+    wxSortCompareFunction m_f;
+};
+
 #define WX_DECLARE_LIST_XO(elT, liT, decl)                                    \
-    decl liT;                                                                 \
-                                                                              \
-    /* Workaround for broken VC6 STL incorrectly requires a std::greater<> */ \
-    /* to be passed into std::list::sort() */                                 \
-    template <>                                                               \
-    struct std::greater<elT>                                                  \
-    {                                                                         \
-        private:                                                              \
-            wxSortCompareFunction m_CompFunc;                                 \
-        public:                                                               \
-            greater( wxSortCompareFunction compfunc = NULL )                  \
-                : m_CompFunc( compfunc ) {}                                   \
-            bool operator()(const elT X, const elT Y) const                   \
-                {                                                             \
-                    return m_CompFunc ?                                       \
-                        ( m_CompFunc( X, Y ) < 0 ) :                          \
-                        ( X > Y );                                            \
-                }                                                             \
-    };                                                                        \
-                                                                              \
     decl liT : public std::list<elT>                                          \
     {                                                                         \
     private:                                                                  \
@@ -269,11 +260,9 @@ enum wxKeyType
                 std::for_each( begin(), end(), DeleteFunction );              \
             clear();                                                          \
         }                                                                     \
-                                                                              \
         /* Workaround for broken VC6 std::list::sort() see above */           \
         void Sort( wxSortCompareFunction compfunc )                           \
-            { sort( std::greater<elT>( compfunc ) ); }                        \
-                                                                              \
+            { sort( wxList_SortFunction<elT>( compfunc ) ); }                 \
         ~liT() { Clear(); }                                                   \
     }