diff options
| author | Tatiana Borisova <tatiana.borisova@qt.io> | 2024-07-11 12:20:26 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-08-01 11:04:23 +0000 |
| commit | 2aa39be4c23ad837c6a09b5cf74c74da670d7ebf (patch) | |
| tree | 84aeb31ac26249e8011f3644f556a0769a4d9af5 /src/corelib/io/qdebug.h | |
| parent | 1442a9ea479d197ed338f440d5106a7e195c4ee2 (diff) | |
Add QDebug printing for the std/Qt::<name>_ordering types
[ChangeLog][QtCore][QDebug] Added possibility to print {std/Qt}
weak/partial/strong_ordering values with QDebug << operator.
Change-Id: Ie880cb34c19f79a404c692c2322b3460d72bfde4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/io/qdebug.h')
| -rw-r--r-- | src/corelib/io/qdebug.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 03f0886304a..f941bf40cb0 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -9,6 +9,7 @@ #pragma qt_class(QtDebug) #endif +#include <QtCore/qcompare.h> #include <QtCore/qcontainerfwd.h> #include <QtCore/qtextstream.h> #include <QtCore/qttypetraits.h> @@ -79,6 +80,8 @@ class QT6_ONLY(Q_CORE_EXPORT) QDebug : public QIODeviceBase QT7_ONLY(Q_CORE_EXPORT) void putTimeUnit(qint64 num, qint64 den); QT7_ONLY(Q_CORE_EXPORT) void putInt128(const void *i); QT7_ONLY(Q_CORE_EXPORT) void putUInt128(const void *i); + QT7_ONLY(Q_CORE_EXPORT) void putQtOrdering(QtOrderingPrivate::QtOrderingTypeFlag flags, + Qt::partial_ordering order); public: explicit QDebug(QIODevice *device) : stream(new Stream(device)) {} explicit QDebug(QString *string) : stream(new Stream(string)) {} @@ -250,6 +253,17 @@ public: { return toBytesImpl(&streamTypeErased<T>, std::addressof(object)); } + +private: + template <typename T> + using if_ordering_type = std::enable_if_t<QtOrderingPrivate::is_ordering_type_v<T>, bool>; + + template <typename T, if_ordering_type<T> = true> + friend QDebug operator<<(QDebug debug, T t) + { + debug.putQtOrdering(QtOrderingPrivate::orderingFlagsFor(t), Qt::partial_ordering(t)); + return debug; + } }; Q_DECLARE_SHARED(QDebug) |
