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:
@@ -14,6 +14,10 @@
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
// these functions are only used in STL build now but we define them in any
|
||||
// case for compatibility with the existing code outside of the library which
|
||||
// could be using them
|
||||
@@ -474,6 +478,16 @@ public:
|
||||
m_data.ptr = strings;
|
||||
}
|
||||
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
// construct an adapter from a vector of strings (of any type)
|
||||
template <class T>
|
||||
wxArrayStringsAdapter(const std::vector<T>& strings)
|
||||
: m_type(wxSTRING_POINTER), m_size(strings.size())
|
||||
{
|
||||
m_data.ptr = &strings[0];
|
||||
}
|
||||
#endif // wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
|
||||
// construct an adapter from a single wxString
|
||||
wxArrayStringsAdapter(const wxString& s)
|
||||
: m_type(wxSTRING_POINTER), m_size(1)
|
||||
|
Reference in New Issue
Block a user