tried to make wxArrayString(bool autosort) ctor more explicit, e.g. prevent it from being used in implicit conversions from char * to wxArrayString
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -989,9 +989,17 @@ public:
|
||||
const wxString& second);
|
||||
|
||||
// constructors and destructor
|
||||
// default ctor: if autoSort is TRUE, the array is always sorted (in
|
||||
// alphabetical order)
|
||||
wxArrayString(bool autoSort = FALSE);
|
||||
// default ctor
|
||||
wxArrayString() { Init(FALSE); }
|
||||
// if autoSort is TRUE, the array is always sorted (in alphabetical order)
|
||||
//
|
||||
// NB: the reason for using int and not bool is that like this we can avoid
|
||||
// using this ctor for implicit conversions from "const char *" (which
|
||||
// we'd like to be implicitly converted to wxString instead!)
|
||||
//
|
||||
// of course, using explicit would be even better - if all compilers
|
||||
// supported it...
|
||||
wxArrayString(int autoSort) { Init(autoSort != 0); }
|
||||
// copy ctor
|
||||
wxArrayString(const wxArrayString& array);
|
||||
// assignment operator
|
||||
@@ -1065,6 +1073,7 @@ public:
|
||||
bool operator!=(const wxArrayString& a) const { return !(*this == a); }
|
||||
|
||||
protected:
|
||||
void Init(bool autoSort); // common part of all ctors
|
||||
void Copy(const wxArrayString& src); // copies the contents of another array
|
||||
|
||||
private:
|
||||
|
@@ -1904,7 +1904,7 @@ wxString& wxString::replace(size_t nStart, size_t nLen,
|
||||
#define STRING(p) ((wxString *)(&(p)))
|
||||
|
||||
// ctor
|
||||
wxArrayString::wxArrayString(bool autoSort)
|
||||
void wxArrayString::Init(bool autoSort)
|
||||
{
|
||||
m_nSize =
|
||||
m_nCount = 0;
|
||||
@@ -1915,10 +1915,7 @@ wxArrayString::wxArrayString(bool autoSort)
|
||||
// copy ctor
|
||||
wxArrayString::wxArrayString(const wxArrayString& src)
|
||||
{
|
||||
m_nSize =
|
||||
m_nCount = 0;
|
||||
m_pItems = (wxChar **) NULL;
|
||||
m_autoSort = src.m_autoSort;
|
||||
Init(src.m_autoSort);
|
||||
|
||||
*this = src;
|
||||
}
|
||||
|
Reference in New Issue
Block a user