diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-09-27 09:43:04 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-09-29 12:45:02 +0000 |
commit | 97c1b02b8b60635fecb2b4865607a6b40d713c56 (patch) | |
tree | 6d276b837d44aecb9a665af2a02e1683d997bf20 | |
parent | 3cd83ab86b37285dcdab4ba1f155fb79ed1e1aa9 (diff) |
Replace QPair by std::pair
Change-Id: Ic64a2a2c162c54fbbfb6ddc5004ffe1944bfd37a
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit 6ab7d0b384b58c52faf924278f032e796ce42f07)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 443d81f8992964e1f3299d00259155a2bde373cf)
14 files changed, 37 insertions, 31 deletions
diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp index 7b351d580..0c8e1886a 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp +++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp @@ -663,7 +663,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type) AutoDecRef items(PyMapping_Items(members)); Py_ssize_t nr_items = PySequence_Length(items); - QList<QPair<QByteArray, int> > entries; + QList<std::pair<QByteArray, int> > entries; for (Py_ssize_t idx = 0; idx < nr_items; ++idx) { AutoDecRef item(PySequence_GetItem(items, idx)); AutoDecRef key(PySequence_GetItem(item, 0)); @@ -671,8 +671,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type) AutoDecRef value(PyObject_GetAttr(member, Shiboken::PyName::value())); auto ckey = String::toCString(key); auto ivalue = PyLong_AsSsize_t(value); - auto thing = QPair<QByteArray, int>(ckey, int(ivalue)); - entries.push_back(thing); + entries.push_back(std::make_pair(ckey, int(ivalue))); } addEnumerator(name, isFlag, true, entries); } diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.h b/sources/pyside6/libpyside/dynamicqmetaobject.h index d5bf12756..dd33f65f7 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.h +++ b/sources/pyside6/libpyside/dynamicqmetaobject.h @@ -10,6 +10,8 @@ #include <QtCore/QMetaObject> #include <QtCore/QMetaMethod> +#include <utility> + class MetaObjectBuilderPrivate; namespace PySide @@ -19,7 +21,7 @@ class MetaObjectBuilder { Q_DISABLE_COPY_MOVE(MetaObjectBuilder) public: - using EnumValue = QPair<QByteArray, int>; + using EnumValue = std::pair<QByteArray, int>; using EnumValues = QList<EnumValue>; MetaObjectBuilder(const char *className, const QMetaObject *metaObject); diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangparser.h b/sources/shiboken6/ApiExtractor/clangparser/clangparser.h index 3abbece24..5e6eba82e 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangparser.h +++ b/sources/shiboken6/ApiExtractor/clangparser/clangparser.h @@ -8,11 +8,11 @@ #include <QtCore/QByteArrayList> #include <QtCore/QHash> -#include <QtCore/QPair> #include <QtCore/QString> #include <QtCore/QList> #include <string_view> +#include <utility> namespace clang { diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp index fbea76b41..68b10d5b4 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp @@ -79,8 +79,8 @@ CXString getFileNameFromLocation(const CXSourceLocation &location) SourceRange getCursorRange(const CXCursor &cursor) { const CXSourceRange extent = clang_getCursorExtent(cursor); - return qMakePair(getExpansionLocation(clang_getRangeStart(extent)), - getExpansionLocation(clang_getRangeEnd(extent))); + return std::make_pair(getExpansionLocation(clang_getRangeStart(extent)), + getExpansionLocation(clang_getRangeEnd(extent))); } QString getCursorKindName(CXCursorKind cursorKind) @@ -222,14 +222,14 @@ QList<Diagnostic> getDiagnostics(CXTranslationUnit tu) return result; } -QPair<qsizetype, qsizetype> +std::pair<qsizetype, qsizetype> parseTemplateArgumentList(const QString &l, const TemplateArgumentHandler &handler, qsizetype from) { const auto ltPos = l.indexOf(u'<', from); if (ltPos == - 1) - return qMakePair(-1, -1); + return std::make_pair(-1, -1); auto startPos = ltPos + 1; int level = 1; for (qsizetype p = startPos, end = l.size(); p < end; ) { @@ -241,7 +241,7 @@ QPair<qsizetype, qsizetype> ++p; if (c == '>') { if (--level == 0) - return qMakePair(ltPos, p); + return std::make_pair(ltPos, p); // Skip over next ',': "a<b<c,d>,e>" for (; p < end && (l.at(p).isSpace() || l.at(p) == u','); ++p) {} } @@ -257,7 +257,7 @@ QPair<qsizetype, qsizetype> break; } } - return qMakePair(-1, -1); + return std::make_pair(-1, -1); } CXDiagnosticSeverity maxSeverity(const QList<Diagnostic> &ds) diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.h b/sources/shiboken6/ApiExtractor/clangparser/clangutils.h index 532807362..4ad21eebe 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.h +++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.h @@ -5,12 +5,12 @@ #define CLANGUTILS_H #include <clang-c/Index.h> -#include <QtCore/QPair> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QList> #include <functional> +#include <utility> QT_FORWARD_DECLARE_CLASS(QDebug) @@ -59,7 +59,7 @@ inline bool operator!=(const SourceLocation &l1, const SourceLocation &l2) SourceLocation getExpansionLocation(const CXSourceLocation &location); -using SourceRange =QPair<SourceLocation, SourceLocation>; +using SourceRange = std::pair<SourceLocation, SourceLocation>; SourceLocation getCursorLocation(const CXCursor &cursor); CXString getFileNameFromLocation(const CXSourceLocation &location); @@ -92,7 +92,7 @@ CXDiagnosticSeverity maxSeverity(const QList<Diagnostic> &ds); // with each match (level and string). Return begin and end of the list. using TemplateArgumentHandler = std::function<void (int, QStringView)>; -QPair<qsizetype, qsizetype> +std::pair<qsizetype, qsizetype> parseTemplateArgumentList(const QString &l, const TemplateArgumentHandler &handler, qsizetype from = 0); diff --git a/sources/shiboken6/ApiExtractor/doxygenparser.cpp b/sources/shiboken6/ApiExtractor/doxygenparser.cpp index a1c93c127..2b8485ff5 100644 --- a/sources/shiboken6/ApiExtractor/doxygenparser.cpp +++ b/sources/shiboken6/ApiExtractor/doxygenparser.cpp @@ -81,7 +81,7 @@ void DoxygenParser::fillDocumentation(const AbstractMetaClassPtr &metaClass) return; } - static const QList<QPair<Documentation::Type, QString>> docTags = { + static const QList<std::pair<Documentation::Type, QString>> docTags = { { Documentation::Brief, u"briefdescription"_s }, { Documentation::Detailed, u"detaileddescription"_s } }; diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.h b/sources/shiboken6/ApiExtractor/parser/codemodel.h index 6e80eca2e..4204da48b 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.h @@ -12,7 +12,6 @@ #include "typeinfo.h" #include <QtCore/QHash> -#include <QtCore/QPair> #include <QtCore/QSet> #include <QtCore/QString> #include <QtCore/QStringList> @@ -20,6 +19,7 @@ #include <QtCore/QWeakPointer> #include <optional> +#include <utility> QT_FORWARD_DECLARE_CLASS(QDebug) diff --git a/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp b/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp index 45e46786f..2ff73f621 100644 --- a/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp +++ b/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp @@ -365,7 +365,8 @@ private: QStack<TypeInfo *> m_parseStack; }; -QPair<qsizetype, qsizetype> TypeInfo::parseTemplateArgumentList(const QString &l, qsizetype from) +std::pair<qsizetype, qsizetype> + TypeInfo::parseTemplateArgumentList(const QString &l, qsizetype from) { return clang::parseTemplateArgumentList(l, clang::TemplateArgumentHandler(TypeInfoTemplateArgumentHandler(this)), from); } diff --git a/sources/shiboken6/ApiExtractor/parser/typeinfo.h b/sources/shiboken6/ApiExtractor/parser/typeinfo.h index d1d3b5cbc..0f1a04f6f 100644 --- a/sources/shiboken6/ApiExtractor/parser/typeinfo.h +++ b/sources/shiboken6/ApiExtractor/parser/typeinfo.h @@ -12,6 +12,8 @@ #include <QtCore/QSharedDataPointer> #include <QtCore/QStringList> +#include <utility> + QT_FORWARD_DECLARE_CLASS(QDebug) QT_FORWARD_DECLARE_CLASS(QTextStream) @@ -79,7 +81,8 @@ public: bool isStdType() const; - QPair<qsizetype, qsizetype> parseTemplateArgumentList(const QString &l, qsizetype from = 0); + std::pair<qsizetype, qsizetype> + parseTemplateArgumentList(const QString &l, qsizetype from = 0); bool equals(const TypeInfo &other) const; diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp index 3f02820c7..a7b68b428 100644 --- a/sources/shiboken6/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp @@ -33,14 +33,14 @@ #include <QtCore/QFile> #include <QtCore/QDebug> #include <QtCore/QDir> -#include <QtCore/QPair> #include <QtCore/QList> #include <QtCore/QRegularExpression> #include <QtCore/QVersionNumber> #include <QtCore/QXmlStreamReader> #include "reporthandler.h" -// #include <tr1/tuple> + #include <algorithm> +#include <utility> using namespace Qt::StringLiterals; @@ -55,7 +55,7 @@ static QString wildcardToRegExp(QString w) return w; } -using ApiVersion =QPair<QRegularExpression, QVersionNumber>; +using ApiVersion = std::pair<QRegularExpression, QVersionNumber>; using ApiVersions = QList<ApiVersion>; Q_GLOBAL_STATIC(ApiVersions, apiVersions) @@ -1270,7 +1270,7 @@ bool TypeDatabase::setApiVersion(const QString& packageWildcardPattern, const QS const QRegularExpression packageRegex(packagePattern); if (!packageRegex.isValid()) return false; - versions.append(qMakePair(packageRegex, versionNumber)); + versions.append(std::make_pair(packageRegex, versionNumber)); return true; } diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index e4aaad78b..febd1057a 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -1141,8 +1141,8 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul // Create an argument for Py_BuildValue() when writing virtual methods. // Return a pair of (argument, format-char). -QPair<QString, QChar> CppGenerator::virtualMethodNativeArg(const AbstractMetaFunctionCPtr &func, - const AbstractMetaArgument &arg) +std::pair<QString, QChar> CppGenerator::virtualMethodNativeArg(const AbstractMetaFunctionCPtr &func, + const AbstractMetaArgument &arg) { if (func->hasConversionRule(TypeSystem::TargetLangCode, arg.argumentIndex() + 1)) return {arg.name() + CONV_RULE_OUT_VAR_SUFFIX, u'N'}; diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.h b/sources/shiboken6/generator/shiboken/cppgenerator.h index 7fee3c0fb..0a59c678f 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.h +++ b/sources/shiboken6/generator/shiboken/cppgenerator.h @@ -13,6 +13,7 @@ #include <QtCore/QHash> #include <memory> +#include <utility> class OverloadDataNode; class OverloadDataRootNode; @@ -61,8 +62,7 @@ private: void writeDestructorNative(TextStream &s, const GeneratorContext &classContext) const; QString getVirtualFunctionReturnTypeName(const AbstractMetaFunctionCPtr &func) const; - static QPair<QString, QChar> - virtualMethodNativeArg(const AbstractMetaFunctionCPtr &func, + static std::pair<QString, QChar> virtualMethodNativeArg(const AbstractMetaFunctionCPtr &func, const AbstractMetaArgument &arg); void writeVirtualMethodNativeVectorCallArgs(TextStream &s, const AbstractMetaFunctionCPtr &func, diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp index 47e24e012..929bc539d 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp @@ -47,6 +47,7 @@ #include <algorithm> #include <limits> #include <memory> +#include <utility> using namespace Qt::StringLiterals; @@ -1690,7 +1691,7 @@ const QHash<int, QString> &ShibokenGenerator::typeSystemConvName() return result; } -using StringPair = QPair<QString, QString>; +using StringPair = std::pair<QString, QString>; void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString &code) const @@ -1772,7 +1773,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa } } } - replacements.append(qMakePair(conversionString, conversion)); + replacements.append(std::make_pair(conversionString, conversion)); } for (const StringPair &rep : std::as_const(replacements)) code.replace(rep.first, rep.second); @@ -2178,7 +2179,7 @@ ShibokenGenerator::filterGroupedOperatorFunctions(const AbstractMetaClassCPtr &m OperatorQueryOptions query) { // ( func_name, num_args ) => func_list - QMap<QPair<QString, int>, AbstractMetaFunctionCList> results; + QMap<std::pair<QString, int>, AbstractMetaFunctionCList> results; auto funcs = metaClass->operatorOverloads(query); auto end = std::remove_if(funcs.begin(), funcs.end(), skipOperatorFunc); funcs.erase(end, funcs.end()); @@ -2204,7 +2205,7 @@ ShibokenGenerator::filterGroupedOperatorFunctions(const AbstractMetaClassCPtr &m } else { args = func->arguments().size(); } - QPair<QString, int > op(func->name(), args); + auto op = std::make_pair(func->name(), args); results[op].append(func); } QList<AbstractMetaFunctionCList> result; diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.h b/sources/shiboken6/generator/shiboken/shibokengenerator.h index ade6e2d56..5b1af9b3c 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.h +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.h @@ -406,7 +406,7 @@ private: QString functionReturnType(const AbstractMetaFunctionCPtr &func, Options options = NoOption) const; /// Utility function for writeCodeSnips. - using ArgumentVarReplacementPair = QPair<AbstractMetaArgument, QString>; + using ArgumentVarReplacementPair = std::pair<AbstractMetaArgument, QString>; using ArgumentVarReplacementList = QList<ArgumentVarReplacementPair>; static ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunctionCPtr &func, |