diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 11:39:19 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-07 17:16:32 +0200 |
commit | ccb65cdb1b8efc4c16e6b6cee4a763f7e9e58e60 (patch) | |
tree | f4b5b0d3c3145c24f7b0d7557f8c8ba6670e338d | |
parent | b29b3eacc3c480c39d84576705d7e1f2716a0645 (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.
Task-number: QTBUG-99313
Change-Id: Ifc205a53ed6809f98d6cd552de901ea7e90716f5
Reviewed-by: Ivan Solovev <ivan.solovev@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 010bddf..d654d80 100644 --- a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp +++ b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp @@ -658,7 +658,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); @@ -674,7 +674,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 65892db..8c8ea47 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.matchView(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)); } |