wxwidgets/tests/strings
Joan Bruguera Micó 19936c2176 Don't clobber std::string_view equality with char *
Make the wxString(std::string_view) constructor explicit.

Otherwise, when comparing a std::string_view with a const char *, the
cast to wxString will be considered as a candidate for the comparison,
ultimately causing an "ambiguous overload for 'operator=='" error.

For example, this sample only builds if the constructor is explicit:

  #include <wx/string.h>
  #include <string_view>

  int main() {
    std::string_view view = "abc";
    const char *str = "abc";
    return view == str;
  }

However, making the constructor explicit will break assignment:

    std::string_view view = "abc";
    wxString s;
    s = view; // Error: no match for "operator="

That we can fix by implementing operator=(std::string_view)

That, however, introduces another ambiguity:

    std::string str = "abc";
    wxString s;
    s = str; // Ambiguous between s = wxString(str)
                              and s = std::string_view(str)

That we can fix by implementing operator=(std::string)

Finally, note that some rather obscure ambiguities remain, such as:

    wxString s;
    s = {"abc", 2}; // Ambiguous between s = wxString("abc", 2)
                                     and s = std::string_view("abc", 2)

Avoiding them is not simple (https://cplusplus.github.io/LWG/issue2946)
and doesn't add much value.

Closes #23834.
2023-09-06 02:44:11 +02:00
..
crt.cpp Remove wxUSE_UNICODE checks as they're always true now 2022-10-27 19:43:30 +02:00
hexconv.cpp Reimplement tests with Catch 2022-12-07 20:52:33 +01:00
iostream.cpp Remove wxUSE_UNICODE checks as they're always true now 2022-10-27 19:43:30 +02:00
numformatter.cpp Use nullptr instead of NULL in the code and documentation 2022-10-18 01:25:25 +02:00
stdstrings.cpp Don't clobber std::string_view equality with char * 2023-09-06 02:44:11 +02:00
strings.cpp Merge branch 'format-unicode-fix' of https://github.com/lanurmi/wxWidgets 2023-04-28 15:06:54 +02:00
tokenizer.cpp Remove wxUSE_UNICODE checks as they're always true now 2022-10-27 19:43:30 +02:00
unichar.cpp Remove wxUSE_UNICODE checks as they're always true now 2022-10-27 19:43:30 +02:00
unicode.cpp Use range for instead of iterators in unit test 2023-03-26 17:56:55 +01:00
vararg.cpp Check that missing format string arguments are detected 2022-11-23 19:21:36 +01:00
vsnprintf.cpp Remove wxUSE_UNICODE checks as they're always true now 2022-10-27 19:43:30 +02:00