X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed1288c1d53072d6db0285d2bd5dca3d72fc8c3e..ef826e249610b0930a11039e30f15bad70c4d7f4:/include/wx/list.h?ds=sidebyside diff --git a/include/wx/list.h b/include/wx/list.h index 62d6c44aa0..cb7023d3b7 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -98,31 +98,64 @@ 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 +{ +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_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: \ bool m_destroy; \ private: \ - class SortCompareFunction \ - { \ - private: \ - wxSortCompareFunction m_CompFunc; \ - public: \ - SortCompareFunction( wxSortCompareFunction compfunc ) \ - : m_CompFunc( compfunc ) {} \ - bool operator()( const elT X, const elT Y ) const \ - { return ( m_CompFunc( X, Y ) < 0 ); } \ - }; \ - \ 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; \ @@ -259,10 +292,9 @@ enum wxKeyType std::for_each( begin(), end(), DeleteFunction ); \ clear(); \ } \ - \ + /* Workaround for broken VC6 std::list::sort() see above */ \ void Sort( wxSortCompareFunction compfunc ) \ - { sort( SortCompareFunction( compfunc ) ); } \ - \ + { sort( WX_LIST_SORTFUNCTION( elT, compfunc ) ); } \ ~liT() { Clear(); } \ } @@ -1170,9 +1202,9 @@ private: #else // if wxUSE_STL -WX_DECLARE_LIST_XO(wxString, wxStringListBase, class WXDLLEXPORT); +WX_DECLARE_LIST_XO(wxString, wxStringListBase, class WXDLLIMPEXP_BASE); -class WXDLLEXPORT wxStringList : public wxStringListBase +class WXDLLIMPEXP_BASE wxStringList : public wxStringListBase { public: compatibility_iterator Append(wxChar* s)