Fix using std::reverse() with wxString iterators in a proper way
The solution with specializing std::iter_swap() for wxString::iterator was not conforming as the iterator was still not swappable, as it is required to be. Fix this by providing std::swap() overload for wxString::iterator, which is correct and even simpler. This allows std::reverse(s.begin(), s.end()) work with clang too and incidentally avoids warnings about the code relying on non-conforming extensions with MSVS 2017 which were due to the fact that iter_swap() workaround wasn't enabled for it, while the new swap() overload is.
This commit is contained in:
@@ -626,13 +626,7 @@ void StdStringTestCase::StdConversion()
|
||||
|
||||
void StdStringTestCase::StdAlgo()
|
||||
{
|
||||
// Unfortunately this currently doesn't work with libc++ in C++11 mode, see
|
||||
// comment near iter_swap() definition in wx/string.h.
|
||||
#if __cplusplus < 201103L || !defined(_LIBCPP_VERSION)
|
||||
wxString s("AB");
|
||||
std::reverse(s.begin(), s.end());
|
||||
CPPUNIT_ASSERT_EQUAL( "BA", s );
|
||||
#else
|
||||
wxLogWarning("Skipping std::reverse() test broken with C++11/libc++");
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user