From a495b1fd23eba3c0c76d7e06542c447845bf798f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Apr 2021 18:52:56 +0200 Subject: [PATCH] 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. --- src/osx/core/cfstring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osx/core/cfstring.cpp b/src/osx/core/cfstring.cpp index c0c0bccd42..977b316282 100644 --- a/src/osx/core/cfstring.cpp +++ b/src/osx/core/cfstring.cpp @@ -28,7 +28,7 @@ wxString wxMacConvertNewlines13To10(const wxString& data) { wxString string(data); - for (auto&& c: string) + for (wxUniCharRef c: string) { if (c == '\r') c = '\n'; @@ -39,7 +39,7 @@ wxString wxMacConvertNewlines13To10(const wxString& data) wxString wxMacConvertNewlines10To13(const wxString& data) { wxString string(data); - for (auto&& c: string) + for (wxUniCharRef c: string) { if (c == '\n') c = '\r';