From: Vadim Zeitlin Date: Thu, 22 Mar 2007 17:26:09 +0000 (+0000) Subject: add operator+=(unsigned char) for backwards compatibility and because we generally... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b77afb41f385fb4b0ffddf1e6d17c0d83963c29b?ds=inline add operator+=(unsigned char) for backwards compatibility and because we generally handle both signed and unisnged chars everywhere; added wxString(const wxCStrData&, size_t) ctor to resolve ambiguity between wxString(const char *, size_t) and wxString(const unsigned char *, size_t) and wxString(const wxString&, size_t) to resolved embiguity for string parameter of ctor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/string.h b/include/wx/string.h index 0642f2ff37..425bb74bf1 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -817,7 +817,7 @@ public: wxCStrData operator+(size_t n) const { return wxCStrData(m_str, m_offset + n, m_owned); } - // this operator is need to make expressions like "*c_str()" or + // this operator is needed to make expressions like "*c_str()" or // "*(c_str() + 2)" work wxUniChar operator*() const; @@ -989,6 +989,16 @@ public: wxString(const unsigned char* psz, size_t nLength) : wxStringBase((const char*)psz, nLength) { } + // as we provide both ctors with this signature for both char and unsigned + // char string, we need to provide one for wxCStrData to resolve ambiguity + wxString(const wxCStrData& cstr, size_t nLength) + : wxStringBase(cstr.AsChar(), nLength) { } + + // and because wxString is convertible to wxCStrData and const wxChar * + // we also need to provide this one + wxString(const wxString& str, size_t nLength) + : wxStringBase(str, 0, nLength) { } + #if wxUSE_WCHAR_T // from wide (Unicode) string wxString(const wchar_t *pwz, @@ -1670,6 +1680,7 @@ public: { return (wxString&)wxStringBase::operator+=(ch); } wxString& operator+=(wxUniCharRef ch) { return *this += wxUniChar(ch); } wxString& operator+=(char ch) { return *this += wxUniChar(ch); } + wxString& operator+=(unsigned char ch) { return *this += wxUniChar(ch); } wxString& operator+=(wchar_t ch) { return *this += wxUniChar(ch); } private: