Merge branch 'list-std'

Fix build in STL mode under OpenVMS.

See https://github.com/wxWidgets/wxWidgets/pull/2528
This commit is contained in:
Vadim Zeitlin
2021-09-23 16:25:51 +02:00
2 changed files with 46 additions and 1 deletions

View File

@@ -188,7 +188,7 @@ private:
{ \
liT* _this = const_cast< liT* >( this ); \
return compatibility_iterator( _this, \
std::find( _this->begin(), _this->end(), e ) ); \
std::find( _this->begin(), _this->end(), (const elT)e ));\
} \
\
bool IsEmpty() const \

View File

@@ -18,6 +18,7 @@
#endif // WX_PRECOMP
#include "wx/list.h"
#include "wx/scopedptr.h"
// --------------------------------------------------------------------------
// test class
@@ -207,6 +208,50 @@ void ListsTestCase::wxListCtorTest()
CPPUNIT_ASSERT( Baz::GetNumber() == 0 );
}
// Check for WX_DECLARE_LIST_3 which is used to define wxWindowList: we can't
// use this class itself here, as it's in the GUI library, so declare something
// similar.
struct ListElementBase
{
virtual ~ListElementBase() { }
};
struct ListElement : ListElementBase
{
explicit ListElement(int n) : m_n(n) { }
int m_n;
};
WX_DECLARE_LIST_3(ListElement, ListElementBase, ElementsList, ElementsListNode, class);
#if wxUSE_STD_CONTAINERS
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(ElementsList)
#else // !wxUSE_STD_CONTAINERS
void ElementsListNode::DeleteData()
{
delete static_cast<ListElement *>(GetData());
}
#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
TEST_CASE("wxWindowList::Find", "[list]")
{
ListElement* const el = new ListElement(17);
wxScopedPtr<ListElementBase> elb(el);
ElementsList l;
l.Append(el);
// We should be able to call Find() with the base class pointer.
ElementsList::compatibility_iterator it = l.Find(elb.get());
CHECK( it == l.GetFirst() );
}
#if wxUSE_STD_CONTAINERS_COMPATIBLY
#include <list>