diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 11:08:21 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-11 23:17:18 +0200 |
commit | aa37e67ef7f5ff22da0ef95fb5221bc1fff9b3ca (patch) | |
tree | be5e1a9733987aed8602eb47618cd1673a594570 /src/tools/moc | |
parent | fd2685c2f0a219c091e028a98ba6cdd154986fec (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, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.
Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/collectjson.cpp | 2 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 4 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 12 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/tools/moc/collectjson.cpp b/src/tools/moc/collectjson.cpp index c0a4b64d7e..d542e2abc4 100644 --- a/src/tools/moc/collectjson.cpp +++ b/src/tools/moc/collectjson.cpp @@ -60,7 +60,7 @@ int collectJson(const QStringList &jsonFiles, const QString &outputFile, bool sk QStringList jsonFilesSorted = jsonFiles; jsonFilesSorted.sort(); - for (const QString &jsonFile : qAsConst(jsonFilesSorted)) { + for (const QString &jsonFile : std::as_const(jsonFilesSorted)) { QFile f(jsonFile); if (!f.open(QIODevice::ReadOnly)) { fprintf(stderr, "Error opening %s for reading\n", qPrintable(jsonFile)); diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 13973645a1..d111380b8f 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -318,7 +318,7 @@ void Generator::generateCode() // // Build stringdata arrays // - for (const QByteArray &s : qAsConst(strings)) { + for (const QByteArray &s : std::as_const(strings)) { fputc(',', out); printStringWithIndentation(out, s); } @@ -667,7 +667,7 @@ void Generator::generateCode() fprintf(out, "// a) You are using a NOTIFY signal that does not exist. Fix it.\n"); fprintf(out, "// b) You are using a NOTIFY signal that does exist (in a parent class) but has a non-empty parameter list. This is a moc limitation.\n"); fprintf(out, "[[maybe_unused]] static void checkNotifySignalValidity_%s(%s *t) {\n", qualifiedClassNameIdentifier.constData(), cdef->qualified.constData()); - for (const QByteArray &nonClassSignal : qAsConst(cdef->nonClassSignalList)) + for (const QByteArray &nonClassSignal : std::as_const(cdef->nonClassSignalList)) fprintf(out, " t->%s();\n", nonClassSignal.constData()); fprintf(out, "}\n"); } diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index a74dc246d7..9c18c3a862 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -968,7 +968,7 @@ void Moc::parse() classHash.insert(def.qualified, def.qualified); } } - for (const auto &n : qAsConst(namespaceList)) { + for (const auto &n : std::as_const(namespaceList)) { if (!n.hasQNamespace) continue; ClassDef def; @@ -1143,7 +1143,7 @@ void Moc::generate(FILE *out, FILE *jsonOutput) QJsonArray classesJsonFormatted; - for (const ClassDef &cdef: qAsConst(classList)) + for (const ClassDef &cdef: std::as_const(classList)) classesJsonFormatted.append(cdef.toJson()); if (!classesJsonFormatted.isEmpty()) @@ -1923,7 +1923,7 @@ QJsonObject ClassDef::toJson() const cls["qualifiedClassName"_L1] = QString::fromUtf8(qualified.constData()); QJsonArray classInfos; - for (const auto &info: qAsConst(classInfoList)) { + for (const auto &info: std::as_const(classInfoList)) { QJsonObject infoJson; infoJson["name"_L1] = QString::fromUtf8(info.name); infoJson["value"_L1] = QString::fromUtf8(info.value); @@ -1950,7 +1950,7 @@ QJsonObject ClassDef::toJson() const QJsonArray props; - for (const PropertyDef &propDef: qAsConst(propertyList)) + for (const PropertyDef &propDef: std::as_const(propertyList)) props.append(propDef.toJson()); if (!props.isEmpty()) @@ -1965,7 +1965,7 @@ QJsonObject ClassDef::toJson() const QJsonArray superClasses; - for (const auto &super: qAsConst(superclassList)) { + for (const auto &super: std::as_const(superclassList)) { const auto name = super.first; const auto access = super.second; QJsonObject superCls; @@ -1978,7 +1978,7 @@ QJsonObject ClassDef::toJson() const cls["superClasses"_L1] = superClasses; QJsonArray enums; - for (const EnumDef &enumDef: qAsConst(enumList)) + for (const EnumDef &enumDef: std::as_const(enumList)) enums.append(enumDef.toJson(*this)); if (!enums.isEmpty()) cls["enums"_L1] = enums; |