Add wxList::AsVector<>() helper.

This can be useful in legacy code using wxList to progressively replace it
with wxVector.

See #14814.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-11-24 17:36:44 +00:00
parent 84523830d5
commit 102540a046
3 changed files with 26 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/string.h"
#include "wx/vector.h"
#if wxUSE_STD_CONTAINERS
#include "wx/beforestd.h"
@@ -1215,6 +1216,23 @@ public:
// compatibility methods
void Sort(wxSortCompareFunction compfunc) { wxListBase::Sort(compfunc); }
#endif // !wxUSE_STD_CONTAINERS
#ifndef __VISUALC6__
template<typename T>
wxVector<T> AsVector() const
{
wxVector<T> vector(size());
size_t i = 0;
for ( const_iterator it = begin(); it != end(); ++it )
{
vector[i++] = static_cast<T>(*it);
}
return vector;
}
#endif // !__VISUALC6__
};
#if !wxUSE_STD_CONTAINERS