Add support for std::string_view to wx vararg functions

Allow using wxPrintf() etc with std::string_view arguments when using
C++17.

This is inefficient but still more convenient than not being able to use
string_view at all.
This commit is contained in:
Vadim Zeitlin
2021-06-20 18:12:34 +02:00
parent fcfe91b16d
commit 8e2cac22ba
2 changed files with 43 additions and 0 deletions

View File

@@ -65,6 +65,11 @@ TEST_CASE("StringPrintf", "[wxString][Printf][vararg]")
wxGCC_WARNING_RESTORE(write-strings)
wxCLANG_WARNING_RESTORE(c++11-compat-deprecated-writable-strings)
#ifdef __cpp_lib_string_view
CHECK( wxString::Format("%s", std::string_view{"foobar", 3}) == "foo" );
CHECK( wxString::Format("%s", std::string_view{"bar"}) == "bar" );
#endif // __cpp_lib_string_view
}
TEST_CASE("CharPrintf", "[wxString][Printf][vararg]")