Allow swapping wxString iterators in C++11 mode
Specialize std::iter_swap() for wxString::iterator in C++11 mode as the default implementation of it doesn't work for iterators using "reference" type different from "value_type&" as is the case for wxString::iterator. This notably allows the code using std::reverse() with wxString iterators to compile in C++11 mode, which wasn't the case before.
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include "wx/wx.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -50,6 +52,7 @@ private:
|
||||
#if wxUSE_STD_STRING
|
||||
CPPUNIT_TEST( StdConversion );
|
||||
#endif
|
||||
CPPUNIT_TEST( StdAlgo );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void StdConstructors();
|
||||
@@ -71,6 +74,7 @@ private:
|
||||
#if wxUSE_STD_STRING
|
||||
void StdConversion();
|
||||
#endif
|
||||
void StdAlgo();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(StdStringTestCase);
|
||||
};
|
||||
@@ -617,3 +621,10 @@ void StdStringTestCase::StdConversion()
|
||||
CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(s11), "" );
|
||||
}
|
||||
#endif // wxUSE_STD_STRING
|
||||
|
||||
void StdStringTestCase::StdAlgo()
|
||||
{
|
||||
wxString s("AB");
|
||||
std::reverse(s.begin(), s.end());
|
||||
CPPUNIT_ASSERT_EQUAL( "BA", s );
|
||||
}
|
||||
|
Reference in New Issue
Block a user