diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 9b64be67ceb..1fb2addc9ed 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -1211,8 +1211,8 @@ QDebug &QDebug::putTupleLikeImplImpl(const char *ns, const char *what, \relates QDebug \since 6.9 - Writes the contents of \a map to \a debug. Both \c Key and - \c T need to support streaming into QDebug. + Writes the contents of \a map to \a debug. Both \c Key and + \c T need to support streaming into QDebug. */ /*! @@ -1220,11 +1220,10 @@ QDebug &QDebug::putTupleLikeImplImpl(const char *ns, const char *what, \relates QDebug \since 6.9 -Writes the contents of \a unordered_set to \a debug. The \c Key type -needs to support streaming into QDebug. + Writes the contents of \a unordered_set to \a debug. The \c Key type + needs to support streaming into QDebug. */ - /*! \fn template QDebug operator<<(QDebug debug, const QHash &hash) \relates QDebug diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index f12b7dba13d..7dc6155259e 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -25,11 +25,14 @@ #include #include #include +#include #include #include #include #include #include +#include +#include #include #include #include @@ -446,7 +449,7 @@ inline QDebug operator<<(QDebug debug, const std::multiset } template -inline QDebug operator<<(QDebug debug, const std::set& set) +inline QDebug operator<<(QDebug debug, const std::set &set) { return QtPrivate::printSequentialContainer(std::move(debug), "std::set", set); } @@ -458,7 +461,7 @@ inline QDebug operator<<(QDebug debug, const std::unordered_map -inline QDebug operator<<(QDebug debug, const std::unordered_set& unordered_set) +inline QDebug operator<<(QDebug debug, const std::unordered_set &unordered_set) { return QtPrivate::printSequentialContainer(std::move(debug), "std::unordered_set", unordered_set); } diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 3b50636dfdd..7592a12a490 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -773,8 +773,8 @@ void tst_QDebug::qDebugStdSet() const { QDebug d = qDebug(); - std::set Set{1, 2, 3, 2, 1}; - d.nospace().noquote() << Set; + std::setset{1, 2, 3, 2, 1}; + d.nospace().noquote() << set; } #ifndef QT_NO_MESSAGELOGCONTEXT file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; @@ -785,15 +785,11 @@ void tst_QDebug::qDebugStdSet() const QCOMPARE(s_line, line); QCOMPARE(s_function, function); - { - qDebug() << std::set{"apple", "banana", "cherry", "banana", "apple"}; - } + qDebug() << std::set{"apple", "banana", "cherry", "banana", "apple"}; QCOMPARE(s_msg, "std::set(\"apple\", \"banana\", \"cherry\")"_L1); - { - qDebug() << std::set{}; - } + qDebug() << std::set{}; QCOMPARE(s_msg, "std::set()"_L1); } @@ -858,25 +854,20 @@ void tst_QDebug::qDebugStdUnorderedMap() const QCOMPARE(s_msgType, QtDebugMsg); QStringList expectedValues = {"std::unordered_map","std::pair(1, One)","std::pair(2, Two)","std::pair(3, Three)"}; - for (const QString &expextedValue : expectedValues) { + + for (const QString &expextedValue : expectedValues) QVERIFY(s_msg.contains(expextedValue)); - } QCOMPARE(s_file, file); QCOMPARE(s_line, line); QCOMPARE(s_function, function); - { - qDebug() << std::unordered_map{{"quarter", 0.25f}, {"half", 0.5f}}; - } + qDebug() << std::unordered_map{{"quarter", 0.25f}, {"half", 0.5f}, {"full", 1.0f}}; - expectedValues= {"std::unordered_map","std::pair(\"quarter\", 0.25)","std::pair(\"half\", 0.5)"}; - for (const QString &expextedValue : expectedValues) { - QVERIFY(s_msg.contains(expextedValue)); - } + expectedValues = {"std::unordered_map","std::pair(\"quarter\", 0.25)","std::pair(\"half\", 0.5)","std::pair(\"full\", 1)"}; + for (const QString &expectedValue : expectedValues) + QVERIFY(s_msg.contains(expectedValue)); - { - qDebug()<< std::unordered_map {}; - } + qDebug()<< std::unordered_map {}; QCOMPARE(s_msg, "std::unordered_map()"_L1); } @@ -898,25 +889,18 @@ void tst_QDebug::qDebugStdUnorderedSet() const QCOMPARE(s_msgType, QtDebugMsg); QStringList expectedValues = {"std::unordered_set", "1", "2", "3"}; - for (const QString &expectedValue : expectedValues) { - QVERIFY(s_msg.contains(expectedValue)); - } - QCOMPARE(s_file, file); - QCOMPARE(s_line, line); - QCOMPARE(s_function, function); - { - qDebug() << std::unordered_set{"apple", "banana", "cherry", "banana", "apple"}; - } + for (const QString &expectedValue : expectedValues) + QVERIFY(s_msg.contains(expectedValue)); + + qDebug() << std::unordered_set{"apple", "banana", "cherry", "banana", "apple"}; + expectedValues = {"std::unordered_set", "\"apple\"", "\"banana\"", "\"cherry\""}; - for (const QString &expectedValue : expectedValues) { + for (const QString &expectedValue : expectedValues) QVERIFY(s_msg.contains(expectedValue)); - } - { - qDebug() << std::unordered_set{}; // Empty set - } + qDebug() << std::unordered_set{}; QCOMPARE(s_msg, "std::unordered_set()"_L1); }