Add wxString::ToStdString() and ToStdWstring().

These trivial helper functions are available in all builds (provided that
wxUSE_STD_STRING is not explicitly set to non-default 0 value) unlike implicit
conversions to std::[w]string which are only available when wxUSE_STL==1.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63938 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-04-11 11:08:49 +00:00
parent 13f0c85aa4
commit e3ab69523b
4 changed files with 70 additions and 10 deletions

View File

@@ -559,15 +559,22 @@ void StdStringTestCase::StdConversion()
wxString s4("hello");
// wxString -> std::string conversion is only available in wxUSE_STL case,
// because it conflicts with conversion to const char*/wchar_t*:
// notice that implicit wxString -> std::string conversion is only
// available in wxUSE_STL case, because it conflicts with conversion to
// const char*/wchar_t*
#if wxUSE_STL
std::string s5 = s4;
#else
std::string s5 = s4.ToStdString();
#endif
CPPUNIT_ASSERT_EQUAL( "hello", s5 );
#if wxUSE_STL
wxStdWideString s6 = s4;
CPPUNIT_ASSERT_EQUAL( "hello", s6 );
#else
wxStdWideString s6 = s4.ToStdWstring();
#endif
CPPUNIT_ASSERT_EQUAL( "hello", s6 );
std::string s7(s4);
CPPUNIT_ASSERT( s7 == "hello" );