diff --git a/docs/changes.txt b/docs/changes.txt index d2fb60c611..f61638fcbd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -241,6 +241,8 @@ All: - Added wxON_BLOCK_EXIT_SET() and wxON_BLOCK_EXIT_NULL() to wx/scopeguard.h. - Added wxEvtHandler::QueueEvent() replacing AddPendingEvent() and wxQueueEvent() replacing wxPostEvent(). +- wxString now uses std::[w]string internally by default, meaning that it is + now thread-safe if the standard library provided with your compiler is. All (Unix): diff --git a/docs/doxygen/mainpages/const_wxusedef.h b/docs/doxygen/mainpages/const_wxusedef.h index 93bb092f42..d80ac6aa89 100644 --- a/docs/doxygen/mainpages/const_wxusedef.h +++ b/docs/doxygen/mainpages/const_wxusedef.h @@ -41,10 +41,11 @@ library: @beginDefList @itemdef{wxUSE_STL, Container classes and wxString are implemented using standard classes and provide the same standard API.} +@itemdef{wxUSE_STD_STRING, wxString is implemented using std::[w]string and can + be constructed from it (but provides wxWidgets-compatible API, in + particular is implicitly convertible to @c char* and not std::[w]string).} @itemdef{wxUSE_STD_IOSTREAM, Standard C++ classes are used instead of or in addition to wx stream classes.} -@itemdef{wxUSE_STD_STRING, wxString can be constructed from std::string (but - provides wxWidgets-compatible API).} @itemdef{wxUSE_UNICODE, Compiled with Unicode support (default in wxWidgets 3.0, non-Unicode build will be deprecated in the future).} @itemdef{wxUSE_UNICODE_WCHAR, wxString uses wchar_t buffer for internal storage diff --git a/include/wx/stringimpl.h b/include/wx/stringimpl.h index 7a9adb99bf..f3cd17cec2 100644 --- a/include/wx/stringimpl.h +++ b/include/wx/stringimpl.h @@ -53,7 +53,18 @@ extern WXDLLIMPEXP_DATA_BASE(const wxStringCharType*) wxEmptyStringImpl; // deal with STL/non-STL/non-STL-but-wxUSE_STD_STRING // ---------------------------------------------------------------------------- -#define wxUSE_STL_BASED_WXSTRING wxUSE_STL +// using STL implies using std::string +#if wxUSE_STL + #undef wxUSE_STD_STRING + #define wxUSE_STD_STRING 1 +#endif + +// we use STL-based string internally if we use std::string at all now, there +// should be no reason to prefer our internal implement but if you really need +// it you can predefine wxUSE_STL_BASED_WXSTRING as 0 when building the library +#ifndef wxUSE_STL_BASED_WXSTRING + #define wxUSE_STL_BASED_WXSTRING wxUSE_STD_STRING +#endif // in both cases we need to define wxStdString #if wxUSE_STL_BASED_WXSTRING || wxUSE_STD_STRING