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:
@@ -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
|
||||
// --------------
|
||||
|
||||
|
Reference in New Issue
Block a user