Use std::string::compare() unconditionally

Don't test for it in configure/CMake and just always use it.
This commit is contained in:
Vadim Zeitlin 2022-10-11 00:10:24 +02:00
parent 0a387693c6
commit 583a426a37
9 changed files with 5 additions and 47 deletions

View file

@ -132,18 +132,6 @@ if(NOT MSVC)
endif()
endif()
wx_check_cxx_source_compiles("
std::string foo, bar;
foo.compare(bar);
foo.compare(1, 1, bar);
foo.compare(1, 1, bar, 1, 1);
foo.compare(\"\");
foo.compare(1, 1, \"\");
foo.compare(1, 1, \"\", 2);"
HAVE_STD_STRING_COMPARE
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 compliant std::string::compare
*/
#cmakedefine HAVE_STD_STRING_COMPARE 1
/*
* Define if your compiler has <hash_map>
*/

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_STRING_COMPARE 1" >>confdefs.h
$as_echo "#define HAVE_STD_UNORDERED_MAP 1" >>confdefs.h
$as_echo "#define HAVE_STD_UNORDERED_SET 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_STRING_COMPARE)
AC_DEFINE(HAVE_STD_UNORDERED_MAP)
AC_DEFINE(HAVE_STD_UNORDERED_SET)
AC_DEFINE(HAVE_TYPE_TRAITS)

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_STRING_COMPARE
#define HAVE_STD_STRING_COMPARE
#endif
#ifndef HAVE_TYPE_TRAITS
#define HAVE_TYPE_TRAITS
#endif

View file

@ -87,9 +87,6 @@ typedef std::wstring wxStdWideString;
typedef wxStdString wxStringImpl;
#else // if !wxUSE_STL_BASED_WXSTRING
// in non-STL mode, compare() is implemented in wxString and not wxStringImpl
#undef HAVE_STD_STRING_COMPARE
// ---------------------------------------------------------------------------
// string data prepended with some housekeeping info (used by wxString class),
// is never used directly (but had to be put here to allow inlining)

View file

@ -741,10 +741,6 @@
*/
#undef VA_LIST_IS_ARRAY
/*
* Define if your compiler has compliant std::string::compare
*/
#undef HAVE_STD_STRING_COMPARE
/*
* Define if your compiler has <hash_map>
*/

View file

@ -807,18 +807,6 @@ typedef pid_t GPid;
*/
#undef VA_LIST_IS_ARRAY
#if defined(__NAMESPACE_STD) && !defined(__NAMESPACE_STD_ONLY)
/*
* Define if your compiler has compliant std::string::compare
*/
#define HAVE_STD_STRING_COMPARE 1
#else
/*
* Define if your compiler has compliant std::string::compare
*/
#undef HAVE_STD_STRING_COMPARE
#endif
/*
* Define if your compiler has <hash_map>
*/

View file

@ -44,7 +44,7 @@
#include <sstream>
#endif
#ifndef HAVE_STD_STRING_COMPARE
#if !wxUSE_STL_BASED_WXSTRING
// string handling functions used by wxString:
#if wxUSE_UNICODE_UTF8
#define wxStringMemcmp memcmp
@ -686,9 +686,9 @@ bool wxString::IsSameAs(wxUniChar c, bool compareWithCase) const
: wxToupper(GetChar(0u)) == wxToupper(c));
}
#ifdef HAVE_STD_STRING_COMPARE
#if wxUSE_STL_BASED_WXSTRING
// NB: Comparison code (both if HAVE_STD_STRING_COMPARE and if not) works with
// NB: Comparison code (both if wxUSE_STL_BASED_WXSTRING and if not) works with
// UTF-8 encoded strings too, thanks to UTF-8's design which allows us to
// sort strings in characters code point order by sorting the byte sequence
// in byte values order (i.e. what strcmp() and memcmp() do).
@ -751,7 +751,7 @@ int wxString::compare(size_t nStart, size_t nLen,
return m_impl.compare(pos, len, str.data, str.len);
}
#else // !HAVE_STD_STRING_COMPARE
#else // !wxUSE_STL_BASED_WXSTRING
static inline int wxDoCmp(const wxStringCharType* s1, size_t l1,
const wxStringCharType* s2, size_t l2)
@ -860,7 +860,7 @@ int wxString::compare(size_t nStart, size_t nLen,
return ::wxDoCmp(m_impl.data() + pos, len, str.data, str.len);
}
#endif // HAVE_STD_STRING_COMPARE/!HAVE_STD_STRING_COMPARE
#endif // wxUSE_STL_BASED_WXSTRING/!wxUSE_STL_BASED_WXSTRING
// ---------------------------------------------------------------------------