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);
|
const wxString& second);
|
||||||
|
|
||||||
// constructors and destructor
|
// constructors and destructor
|
||||||
// default ctor: if autoSort is TRUE, the array is always sorted (in
|
// default ctor
|
||||||
// alphabetical order)
|
wxArrayString() { Init(FALSE); }
|
||||||
wxArrayString(bool autoSort = 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
|
// copy ctor
|
||||||
wxArrayString(const wxArrayString& array);
|
wxArrayString(const wxArrayString& array);
|
||||||
// assignment operator
|
// assignment operator
|
||||||
@@ -1065,6 +1073,7 @@ public:
|
|||||||
bool operator!=(const wxArrayString& a) const { return !(*this == a); }
|
bool operator!=(const wxArrayString& a) const { return !(*this == a); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void Init(bool autoSort); // common part of all ctors
|
||||||
void Copy(const wxArrayString& src); // copies the contents of another array
|
void Copy(const wxArrayString& src); // copies the contents of another array
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -1904,7 +1904,7 @@ wxString& wxString::replace(size_t nStart, size_t nLen,
|
|||||||
#define STRING(p) ((wxString *)(&(p)))
|
#define STRING(p) ((wxString *)(&(p)))
|
||||||
|
|
||||||
// ctor
|
// ctor
|
||||||
wxArrayString::wxArrayString(bool autoSort)
|
void wxArrayString::Init(bool autoSort)
|
||||||
{
|
{
|
||||||
m_nSize =
|
m_nSize =
|
||||||
m_nCount = 0;
|
m_nCount = 0;
|
||||||
@@ -1915,10 +1915,7 @@ wxArrayString::wxArrayString(bool autoSort)
|
|||||||
// copy ctor
|
// copy ctor
|
||||||
wxArrayString::wxArrayString(const wxArrayString& src)
|
wxArrayString::wxArrayString(const wxArrayString& src)
|
||||||
{
|
{
|
||||||
m_nSize =
|
Init(src.m_autoSort);
|
||||||
m_nCount = 0;
|
|
||||||
m_pItems = (wxChar **) NULL;
|
|
||||||
m_autoSort = src.m_autoSort;
|
|
||||||
|
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user