diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-11-11 16:26:04 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-11-15 14:24:36 +0100 |
commit | 0fbff58b7dc4dc84147aa9be6592392caf0ebe3f (patch) | |
tree | 32220ae248fef5e3c6ad9a63a10267bcb22f8531 | |
parent | ef966faeca4ec1a846993b13bfc05fa86e004c2b (diff) |
Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.
This is a 6.4 re-run of the script we ran in dev, in order to avoid
conflicts between the branches when cherry-picking.
Change-Id: I5eca3df3179dfb2b2682c75a479ba9a4259cc703
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp | 4 | ||||
-rw-r--r-- | src/remoteobjects/qremoteobjectnode.cpp | 4 | ||||
-rw-r--r-- | src/remoteobjects/qremoteobjectsourceio.cpp | 4 | ||||
-rw-r--r-- | src/repparser/parser.g | 4 | ||||
-rw-r--r-- | src/repparser/qregexparser.h | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp index 69e86ea..a4e43c0 100644 --- a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp +++ b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp @@ -657,7 +657,7 @@ void QAbstractItemModelReplicaImplementation::fetchPendingHeaderData() QList<int> roles; QList<int> sections; QList<Qt::Orientation> orientations; - for (const RequestedHeaderData &data : qAsConst(m_requestedHeaderData)) { + for (const RequestedHeaderData &data : std::as_const(m_requestedHeaderData)) { roles.push_back(data.role); sections.push_back(data.section); orientations.push_back(data.orientation); @@ -673,7 +673,7 @@ void QAbstractItemModelReplicaImplementation::onLayoutChanged(const QtPrivate::I QAbstractItemModel::LayoutChangeHint hint) { QList<QPersistentModelIndex> indexes; - for (const QtPrivate::ModelIndex &parent : qAsConst(parents)) { + for (const QtPrivate::ModelIndex &parent : std::as_const(parents)) { const QModelIndex parentIndex = toQModelIndex(QtPrivate::IndexList{parent}, q); indexes << QPersistentModelIndex(parentIndex); } diff --git a/src/remoteobjects/qremoteobjectnode.cpp b/src/remoteobjects/qremoteobjectnode.cpp index 2eae0bd..4a2e698 100644 --- a/src/remoteobjects/qremoteobjectnode.cpp +++ b/src/remoteobjects/qremoteobjectnode.cpp @@ -1422,7 +1422,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) // We need to make sure all of the source objects are in connectedSources before we add connections, // otherwise nested QObjects could fail (we want to acquire children before parents, and the object // list is unordered) - for (const auto &remoteObject : qAsConst(rxObjects)) { + for (const auto &remoteObject : std::as_const(rxObjects)) { qROPrivDebug() << " connectedSources.contains(" << remoteObject << ")" << connectedSources.contains(remoteObject.name) << replicas.contains(remoteObject.name); if (!connectedSources.contains(remoteObject.name)) { connectedSources[remoteObject.name] = SourceInfo{connection, remoteObject.typeName, remoteObject.signature}; @@ -1432,7 +1432,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) handleReplicaConnection(remoteObject.name); } } - for (const auto &remoteObject : qAsConst(rxObjects)) { + for (const auto &remoteObject : std::as_const(rxObjects)) { if (replicas.contains(remoteObject.name)) //We have a replica waiting on this remoteObject handleReplicaConnection(remoteObject.name); } diff --git a/src/remoteobjects/qremoteobjectsourceio.cpp b/src/remoteobjects/qremoteobjectsourceio.cpp index eed93e9..0b14999 100644 --- a/src/remoteobjects/qremoteobjectsourceio.cpp +++ b/src/remoteobjects/qremoteobjectsourceio.cpp @@ -124,7 +124,7 @@ void QRemoteObjectSourceIo::onServerDisconnect(QObject *conn) qRODebug(this) << "OnServerDisconnect"; - for (QRemoteObjectRootSource *root : qAsConst(m_sourceRoots)) + for (QRemoteObjectRootSource *root : std::as_const(m_sourceRoots)) root->removeListener(connection); const QUrl location = m_registryMapping.value(connection); @@ -277,7 +277,7 @@ void QRemoteObjectSourceIo::newConnection(QtROIoDeviceBase *conn) QRemoteObjectPackets::ObjectInfoList infos; infos.reserve(m_sourceRoots.size()); - for (auto remoteObject : qAsConst(m_sourceRoots)) { + for (auto remoteObject : std::as_const(m_sourceRoots)) { infos << QRemoteObjectPackets::ObjectInfo{remoteObject->m_api->name(), remoteObject->m_api->typeName(), remoteObject->m_api->objectSignature()}; } m_codec->serializeObjectListPacket(infos); diff --git a/src/repparser/parser.g b/src/repparser/parser.g index a8d3e0b..25883e7 100644 --- a/src/repparser/parser.g +++ b/src/repparser/parser.g @@ -817,13 +817,13 @@ void RepParser::TypeParser::generateFunctionParameter(QString variableName, cons void RepParser::TypeParser::appendParams(ASTFunction &slot) { - for (const ASTDeclaration &arg : qAsConst(arguments)) + for (const ASTDeclaration &arg : std::as_const(arguments)) slot.params << arg; } void RepParser::TypeParser::appendPods(POD &pods) { - for (const ASTDeclaration &arg : qAsConst(arguments)) { + for (const ASTDeclaration &arg : std::as_const(arguments)) { PODAttribute attr; attr.type = arg.type; attr.name = arg.name; diff --git a/src/repparser/qregexparser.h b/src/repparser/qregexparser.h index 65316c6..60312b3 100644 --- a/src/repparser/qregexparser.h +++ b/src/repparser/qregexparser.h @@ -303,7 +303,7 @@ int QRegexParser<_Parser, _Table>::nextToken() const QStringView tmp = buffer.mid(m_loc,1); int i = 0; regexCandidates[nextChar] = QList<int>(); - for (const QRegularExpression &re : qAsConst(m_regexes)) + for (const QRegularExpression &re : std::as_const(m_regexes)) { QRegularExpressionMatch match = re.match(tmp, 0, QRegularExpression::PartialPreferFirstMatch, QRegularExpression::DontCheckSubjectStringMatchOption); //qDebug() << nextChar << tmp << match.hasMatch() << match.hasPartialMatch() << re.pattern(); @@ -340,7 +340,7 @@ int QRegexParser<_Parser, _Table>::nextToken() m_captured.insert(iter.value(), bestRegex.captured(iter.key())); if (m_debug) { qDebug() << "Match candidates:"; - for (const MatchCandidate &m : qAsConst(candidates)) { + for (const MatchCandidate &m : std::as_const(candidates)) { QLatin1String result = m.index == best ? QLatin1String(" * ") : QLatin1String(" "); qDebug() << qPrintable(result) << qPrintable(m.name) << qPrintable(escapeString(m.matchText)); } |