From 168da56b8f739937dd49e5ca864a76a3b0a7e99a Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Mon, 14 Mar 2005 21:52:57 +0000 Subject: [PATCH] Blind fix for VC6 compilation when wxUSE_STL == 1. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/list.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/include/wx/list.h b/include/wx/list.h index 136aeaf0f3..5f8dcc4136 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -98,6 +98,8 @@ enum wxKeyType #define WX_DECLARE_LIST_WITH_DECL(elT, liT, decl) \ WX_DECLARE_LIST_XO(elT*, liT, decl) +#if !defined( __VISUALC__ ) + template class WXDLLIMPEXP_BASE wxList_SortFunction { @@ -109,7 +111,37 @@ private: wxSortCompareFunction m_f; }; +#define WX_LIST_SORTFUNCTION( elT, f ) wxList_SortFunction(f) +#define VC6_WORKAROUND(elT, liT, decl) + +#else // if defined( __VISUALC__ ) + +#define WX_LIST_SORTFUNCTION( elT, f ) std::greater( f ) ) +#define VC6_WORKAROUND(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 \ + { \ + 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 ); \ + } \ + }; + +#endif // defined( __VISUALC__ ) + #define WX_DECLARE_LIST_XO(elT, liT, decl) \ + VC6_WORKAROUND(elT, liT, decl) \ decl liT : public std::list \ { \ private: \ @@ -262,7 +294,7 @@ private: } \ /* Workaround for broken VC6 std::list::sort() see above */ \ void Sort( wxSortCompareFunction compfunc ) \ - { sort( wxList_SortFunction( compfunc ) ); } \ + { sort( WX_LIST_SORTFUNCTION( elT, compfunc ) ); } \ ~liT() { Clear(); } \ }