Use std::wstring unconditionally

Don't test for its existence in configure and CMake and don't use
wxStdWideString in the code.
This commit is contained in:
Vadim Zeitlin 2022-10-11 00:06:41 +02:00
parent eb97bf90e4
commit 0a387693c6
14 changed files with 25 additions and 58 deletions

View file

@ -144,12 +144,6 @@ wx_check_cxx_source_compiles("
string
)
wx_check_cxx_source_compiles(
"std::wstring s;"
HAVE_STD_WSTRING
string
)
wx_check_cxx_source_compiles("
std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;"

View file

@ -741,10 +741,6 @@
*/
#cmakedefine VA_LIST_IS_ARRAY 1
/*
* Define if your compiler has std::wstring
*/
#cmakedefine HAVE_STD_WSTRING 1
/*
* Define if your compiler has compliant std::string::compare
*/

2
configure vendored
View file

@ -24728,8 +24728,6 @@ if test "x$COMPAQCXX" = "xyes"; then
CXXFLAGS="-w0 -msg_disable basclsnondto,unrimpret,intconlosbit"
fi
$as_echo "#define HAVE_STD_WSTRING 1" >>confdefs.h
$as_echo "#define HAVE_STD_STRING_COMPARE 1" >>confdefs.h
$as_echo "#define HAVE_STD_UNORDERED_MAP 1" >>confdefs.h

View file

@ -1880,7 +1880,6 @@ if test "x$COMPAQCXX" = "xyes"; then
CXXFLAGS="-w0 -msg_disable basclsnondto,unrimpret,intconlosbit"
fi
AC_DEFINE(HAVE_STD_WSTRING)
AC_DEFINE(HAVE_STD_STRING_COMPARE)
AC_DEFINE(HAVE_STD_UNORDERED_MAP)
AC_DEFINE(HAVE_STD_UNORDERED_SET)

View file

@ -315,10 +315,6 @@ typedef short int WXTYPE;
/* for consistency with wxStatic/DynamicCast defined in wx/object.h */
#define wxConstCast(obj, className) const_cast<className *>(obj)
#ifndef HAVE_STD_WSTRING
#define HAVE_STD_WSTRING
#endif
#ifndef HAVE_STD_STRING_COMPARE
#define HAVE_STD_STRING_COMPARE
#endif

View file

@ -22,7 +22,6 @@
#define wx_USE_NANOX 0
#define HAVE_VA_COPY 1
#define HAVE_STD_WSTRING 1
#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 2 )
#if !defined(__has_include)
#define HAVE_TR1_UNORDERED_MAP 1

View file

@ -1239,9 +1239,9 @@ public:
// they need it
#if wxUSE_STD_STRING
#if wxUSE_UNICODE_WCHAR
wxString(const wxStdWideString& str) : m_impl(str) {}
wxString(const std::wstring& str) : m_impl(str) {}
#else // UTF-8 or ANSI
wxString(const wxStdWideString& str)
wxString(const std::wstring& str)
{ assign(str.c_str(), str.length()); }
#endif
@ -1262,12 +1262,12 @@ public:
// We can avoid a copy if we already use this string type internally,
// otherwise we create a copy on the fly:
#if wxUSE_UNICODE_WCHAR && wxUSE_STL_BASED_WXSTRING
#define wxStringToStdWstringRetType const wxStdWideString&
const wxStdWideString& ToStdWstring() const { return m_impl; }
#define wxStringToStdWstringRetType const std::wstring&
const std::wstring& ToStdWstring() const { return m_impl; }
#else
// wxStringImpl is either not std::string or needs conversion
#define wxStringToStdWstringRetType wxStdWideString
wxStdWideString ToStdWstring() const
#define wxStringToStdWstringRetType std::wstring
std::wstring ToStdWstring() const
{
#if wxUSE_UNICODE_WCHAR
wxScopedWCharBuffer buf =
@ -1276,7 +1276,7 @@ public:
wxScopedWCharBuffer buf(wc_str());
#endif
return wxStdWideString(buf.data(), buf.length());
return std::wstring(buf.data(), buf.length());
}
#endif

View file

@ -66,14 +66,11 @@ extern WXDLLIMPEXP_DATA_BASE(const wxStringCharType*) wxEmptyStringImpl;
#include <string>
#include "wx/afterstd.h"
#ifdef HAVE_STD_WSTRING
typedef std::wstring wxStdWideString;
#else
typedef std::basic_string<wchar_t> wxStdWideString;
#endif
// Define this for compatibility only, it is not used any longer.
typedef std::wstring wxStdWideString;
#if wxUSE_UNICODE_WCHAR
typedef wxStdWideString wxStdString;
typedef std::wstring wxStdString;
#else
typedef std::string wxStdString;
#endif

View file

@ -816,10 +816,10 @@ struct wxArgNormalizerWchar<const std::string_view&>
#endif // NO_IMPLICIT_WXSTRING_ENCODING
template<>
struct wxArgNormalizerWchar<const wxStdWideString&>
struct wxArgNormalizerWchar<const std::wstring&>
: public wxArgNormalizerWchar<const wchar_t*>
{
wxArgNormalizerWchar(const wxStdWideString& s,
wxArgNormalizerWchar(const std::wstring& s,
const wxFormatString *fmt, unsigned index)
: wxArgNormalizerWchar<const wchar_t*>(s.c_str(), fmt, index) {}
};
@ -850,10 +850,10 @@ struct wxArgNormalizerUtf8<const std::string_view&>
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
template<>
struct wxArgNormalizerUtf8<const wxStdWideString&>
struct wxArgNormalizerUtf8<const std::wstring&>
: public wxArgNormalizerUtf8<const wchar_t*>
{
wxArgNormalizerUtf8(const wxStdWideString& s,
wxArgNormalizerUtf8(const std::wstring& s,
const wxFormatString *fmt, unsigned index)
: wxArgNormalizerUtf8<const wchar_t*>(s.c_str(), fmt, index) {}
};
@ -865,7 +865,7 @@ WX_ARG_NORMALIZER_FORWARD(std::string, const std::string&);
WX_ARG_NORMALIZER_FORWARD(std::string_view, const std::string_view&);
#endif // __cpp_lib_string_view
#endif
WX_ARG_NORMALIZER_FORWARD(wxStdWideString, const wxStdWideString&);
WX_ARG_NORMALIZER_FORWARD(std::wstring, const std::wstring&);
#endif // wxUSE_STD_STRING

View file

@ -243,14 +243,14 @@ public:
operator std::string() const { return (operator wxString()).ToStdString(); }
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
wxVariant(const wxStdWideString& val, const wxString& name = wxEmptyString);
bool operator==(const wxStdWideString& value) const
wxVariant(const std::wstring& val, const wxString& name = wxEmptyString);
bool operator==(const std::wstring& value) const
{ return operator==(wxString(value)); }
bool operator!=(const wxStdWideString& value) const
bool operator!=(const std::wstring& value) const
{ return operator!=(wxString(value)); }
wxVariant& operator=(const wxStdWideString& value)
wxVariant& operator=(const std::wstring& value)
{ return operator=(wxString(value)); }
operator wxStdWideString() const { return (operator wxString()).ToStdWstring(); }
operator std::wstring() const { return (operator wxString()).ToStdWstring(); }
#endif // wxUSE_STD_STRING
// wxUniChar

View file

@ -741,10 +741,6 @@
*/
#undef VA_LIST_IS_ARRAY
/*
* Define if your compiler has std::wstring
*/
#undef HAVE_STD_WSTRING
/*
* Define if your compiler has compliant std::string::compare
*/

View file

@ -808,19 +808,11 @@ typedef pid_t GPid;
#undef VA_LIST_IS_ARRAY
#if defined(__NAMESPACE_STD) && !defined(__NAMESPACE_STD_ONLY)
/*
* Define if your compiler has std::wstring
*/
#define HAVE_STD_WSTRING 1
/*
* Define if your compiler has compliant std::string::compare
*/
#define HAVE_STD_STRING_COMPARE 1
#else
/*
* Define if your compiler has std::wstring
*/
/* #unfine HAVE_STD_WSTRING */
/*
* Define if your compiler has compliant std::string::compare
*/

View file

@ -976,7 +976,7 @@ wxVariant::wxVariant(const std::string& val, const wxString& name)
m_name = name;
}
wxVariant::wxVariant(const wxStdWideString& val, const wxString& name)
wxVariant::wxVariant(const std::wstring& val, const wxString& name)
{
m_refData = new wxVariantDataString(wxString(val));
m_name = name;

View file

@ -526,7 +526,7 @@ TEST_CASE("StdString::Substr", "[stdstring]")
TEST_CASE("StdString::Conversion", "[stdstring]")
{
std::string strStd("std::string value");
wxStdWideString strStdWide(L"std::wstring value");
std::wstring strStdWide(L"std::wstring value");
wxString s1(strStd);
CHECK( s1 == "std::string value" );
@ -553,9 +553,9 @@ TEST_CASE("StdString::Conversion", "[stdstring]")
CHECK( s5 == "hello" );
#if wxUSE_STL
wxStdWideString s6 = s4;
std::wstring s6 = s4;
#else
wxStdWideString s6 = s4.ToStdWstring();
std::wstring s6 = s4.ToStdWstring();
#endif
CHECK( s6 == "hello" );
@ -564,7 +564,7 @@ TEST_CASE("StdString::Conversion", "[stdstring]")
CHECK( s7 == "hello" );
#endif
wxStdWideString s8(s4);
std::wstring s8(s4);
CHECK( s8 == "hello" );
#if wxUSE_UNICODE