Add a new wxUSE_STD_CONTAINERS_COMPATIBLY option.

This option, which is on by default unless the use of STL is disabled,
provides better interoperability with the standard library when it can be done
without breaking backwards compatibility.

The first example of its use is to allow passing std::vector<> of any string
compatible type to wxItemContainer::Append(), Insert() and Set(), allowing to
directly initialize various wxControls deriving from it such as wxChoice,
wxComboBox, wxListBox from a std::vector<> of strings.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78066 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-10-24 21:54:51 +00:00
parent 30c93fd705
commit 722057b3a0
16 changed files with 253 additions and 8 deletions

View File

@@ -216,6 +216,10 @@ public:
wxClientData **clientData)
{ return AppendItems(wxArrayStringsAdapter(n, items), clientData); }
template <class T>
int Append(const std::vector<T>& items)
{ return AppendItems(items); }
// only for RTTI needs (separate name)
void AppendString(const wxString& item)
{ Append(item); }
@@ -255,6 +259,9 @@ public:
wxClientData **clientData)
{ return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); }
template <class T>
int Insert(const std::vector<T>& items, unsigned int pos)
{ return InsertItems(items, pos); }
// replacing items
// ---------------
@@ -272,6 +279,10 @@ public:
void Set(unsigned int n, const wxString *items, wxClientData **clientData)
{ Clear(); Append(n, items, clientData); }
template <class T>
void Set(const std::vector<T>& items)
{ Clear(); Append(items); }
// deleting items
// --------------