Use wxUniCharRef rather than "auto&&" to iterate over wxString

As explained in 0a5be41f8a (Avoid using uninitialized static wxString in
wxOSX code, 2021-04-04), the usual "auto&" can't be used to iterate over
wxString and modify its contents because of proxy-like nature of
wxUniCharRef returned by wxString iterators.

But using "auto&&" as that commit did wasn't especially clear (even with
the explanations in the commit message) and gave -Wrange-loop-analysis
when using clang.

So replace it with "wxUniCharRef", which should be both more clear (it
is a value, which is still a bit confusing, but its name hopefully
indicates that it's also some kind of a reference) and warning-free.
This commit is contained in:
Vadim Zeitlin
2021-04-06 18:52:56 +02:00
parent e5011b46ae
commit a495b1fd23

View File

@@ -28,7 +28,7 @@
wxString wxMacConvertNewlines13To10(const wxString& data) wxString wxMacConvertNewlines13To10(const wxString& data)
{ {
wxString string(data); wxString string(data);
for (auto&& c: string) for (wxUniCharRef c: string)
{ {
if (c == '\r') if (c == '\r')
c = '\n'; c = '\n';
@@ -39,7 +39,7 @@ wxString wxMacConvertNewlines13To10(const wxString& data)
wxString wxMacConvertNewlines10To13(const wxString& data) wxString wxMacConvertNewlines10To13(const wxString& data)
{ {
wxString string(data); wxString string(data);
for (auto&& c: string) for (wxUniCharRef c: string)
{ {
if (c == '\n') if (c == '\n')
c = '\r'; c = '\r';