From 831c288955569b2e923f435154a0439c3dee979e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Mar 2005 22:12:46 +0000 Subject: [PATCH] compilation fix for VC6 (patch 1158433) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32647 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/list.h | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/include/wx/list.h b/include/wx/list.h index 5c3c22b942..97a965b246 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -99,30 +99,40 @@ enum wxKeyType WX_DECLARE_LIST_XO(elT*, liT, decl) #define WX_DECLARE_LIST_XO(elT, liT, decl) \ - decl liT : public std::list \ + decl liT; \ + \ + /* Workaround for broken VC6 STL incorrectly requires a std::greater<> */ \ + /* to be passed into std::list::sort() */ \ + template <> \ + struct std::greater \ { \ - private: \ - bool m_destroy; \ - private: \ - class SortCompareFunction \ - { \ private: \ wxSortCompareFunction m_CompFunc; \ public: \ - SortCompareFunction( wxSortCompareFunction compfunc ) \ + greater( wxSortCompareFunction compfunc = NULL ) \ : m_CompFunc( compfunc ) {} \ - bool operator()( const elT X, const elT Y ) const \ - { return ( m_CompFunc( X, Y ) < 0 ); } \ - }; \ + bool operator()(const elT X, const elT Y) const \ + { \ + return m_CompFunc ? \ + ( m_CompFunc( X, Y ) < 0 ) : \ + ( X > Y ); \ + } \ + }; \ \ + decl liT : public std::list \ + { \ + private: \ + bool m_destroy; \ + private: \ typedef elT _WX_LIST_ITEM_TYPE_##liT; \ static void DeleteFunction( const _WX_LIST_ITEM_TYPE_##liT X ); \ public: \ class compatibility_iterator \ { \ private: \ - typedef liT::iterator iterator; \ - friend class liT; \ + /* Workaround for broken VC6 nested class name resolution */ \ + typedef std::list::iterator iterator; \ + friend class liT; \ private: \ iterator m_iter; \ liT * m_list; \ @@ -260,8 +270,9 @@ enum wxKeyType clear(); \ } \ \ + /* Workaround for broken VC6 std::list::sort() see above */ \ void Sort( wxSortCompareFunction compfunc ) \ - { sort( SortCompareFunction( compfunc ) ); } \ + { sort( std::greater( compfunc ) ); } \ \ ~liT() { Clear(); } \ } -- 2.45.2