QCalendar: fix build
Apple Clang 12:
qcalendar.cpp:456:22: error: loop variable '[key, value]' is always a copy because the range of type 'QFlatMap<QString,
QCalendarBackend *, (anonymous namespace)::CaseInsensitiveAnyStringViewLessThan, QStringList, std::vector<QCalendarBackend *>
>' (aka 'QFlatMap<QString, QCalendarBackend *, (anonymous namespace)::CaseInsensitiveAnyStringViewLessThan, QList<QString>,
vector<QCalendarBackend *> >') does not return a reference [-Werror,-Wrange-loop-analysis]
for (const auto &[key, value] : byName) {
^
Change-Id: I54f205f6b7314351b078fffd16d05e5cd3ef4c22
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
parent
013d0fcf5f
commit
7277ffee52
|
|
@ -453,10 +453,16 @@ QStringList QCalendarRegistry::backendNames(const QCalendarBackend *backend)
|
|||
QStringList l;
|
||||
l.reserve(byName.size()); // too large, but never really large, so ok
|
||||
|
||||
QT_WARNING_PUSH
|
||||
// Clang complains about the reference still causing a copy. The reference is idiomatic, but
|
||||
// runs afoul of QFlatMap's iterators which return a pair of references instead of a reference
|
||||
// to pair. Suppress the warning, because `const auto [key, value]` would look wrong.
|
||||
QT_WARNING_DISABLE_CLANG("-Wrange-loop-analysis")
|
||||
for (const auto &[key, value] : byName) {
|
||||
if (value == backend)
|
||||
l.push_back(key);
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue