X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3871d4ca7599c1156e4cca908ebdeb1474608650..4e2251ecd324ba89c486434485efcb1d32ee7dca:/include/wx/list.h diff --git a/include/wx/list.h b/include/wx/list.h index b875444930..8c19a070ec 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -136,7 +136,7 @@ private: #endif // defined( __VISUALC__ ) /* - Note: the outer helper class _WX_LIST_HELPER_##liT below is a workaround + Note 1: the outer helper class _WX_LIST_HELPER_##liT below is a workaround for mingw 3.2.3 compiler bug that prevents a static function of liT class from being exported into dll. A minimal code snippet reproducing the bug: @@ -155,6 +155,13 @@ private: The program does not link under mingw_gcc 3.2.3 producing undefined reference to Foo::Bar() function + + + Note 2: the EmptyList is needed to allow having a NULL pointer-like + invalid iterator. We used to use just an uninitialized iterator object + instead but this fails with some debug/checked versions of STL, notably the + glibc version activated with _GLIBCXX_DEBUG, so we need to have a separate + invalid iterator. */ // the real wxList-class declaration @@ -170,6 +177,9 @@ private: decl liT : public std::list \ { \ private: \ + typedef std::list BaseListType; \ + static BaseListType EmptyList; \ + \ bool m_destroy; \ public: \ decl compatibility_iterator \ @@ -183,7 +193,7 @@ private: liT * m_list; \ public: \ compatibility_iterator() \ - : m_iter(), m_list( NULL ) {} \ + : m_iter(EmptyList.end()), m_list( NULL ) {} \ compatibility_iterator( liT* li, iterator i ) \ : m_iter( i ), m_list( li ) {} \ compatibility_iterator( const liT* li, iterator i ) \ @@ -252,6 +262,11 @@ private: std::advance( i, idx ); \ return compatibility_iterator( this, i ); \ } \ + elT operator[](size_t idx) const \ + { \ + return Item(idx).GetData(); \ + } \ + \ compatibility_iterator GetFirst() const \ { \ return compatibility_iterator( this, \