diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index aa69a1ae237..76fea1a3e0f 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -250,6 +250,20 @@ inline QDebug printSequentialContainer(QDebug debug, const char *which, const Se return debug.maybeSpace(); } +template +inline QDebug printAssociativeContainer(QDebug debug, const char *which, const AssociativeContainer &c) +{ + const bool oldSetting = debug.autoInsertSpaces(); + debug.nospace() << which << "("; + for (typename AssociativeContainer::const_iterator it = c.constBegin(); + it != c.constEnd(); ++it) { + debug << '(' << it.key() << ", " << it.value() << ')'; + } + debug << ')'; + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); +} + } // namespace QtPrivate template @@ -285,28 +299,25 @@ inline QDebug operator<<(QDebug debug, const std::multimap inline QDebug operator<<(QDebug debug, const QMap &map) { - const bool oldSetting = debug.autoInsertSpaces(); - debug.nospace() << "QMap("; - for (typename QMap::const_iterator it = map.constBegin(); - it != map.constEnd(); ++it) { - debug << '(' << it.key() << ", " << it.value() << ')'; - } - debug << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return QtPrivate::printAssociativeContainer(debug, "QMap", map); +} + +template +inline QDebug operator<<(QDebug debug, const QMultiMap &map) +{ + return QtPrivate::printAssociativeContainer(debug, "QMultiMap", map); } template inline QDebug operator<<(QDebug debug, const QHash &hash) { - const bool oldSetting = debug.autoInsertSpaces(); - debug.nospace() << "QHash("; - for (typename QHash::const_iterator it = hash.constBegin(); - it != hash.constEnd(); ++it) - debug << '(' << it.key() << ", " << it.value() << ')'; - debug << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return QtPrivate::printAssociativeContainer(debug, "QHash", hash); +} + +template +inline QDebug operator<<(QDebug debug, const QMultiHash &hash) +{ + return QtPrivate::printAssociativeContainer(debug, "QMultiHash", hash); } template