diff options
Diffstat (limited to 'src/corelib/io/qdebug.h')
| -rw-r--r-- | src/corelib/io/qdebug.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index f5a35236e1a..770f4fac9a8 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -126,6 +126,7 @@ public: inline QDebug &operator<<(QByteArrayView t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(std::nullptr_t) { stream->ts << "(nullptr)"; return maybeSpace(); } + inline QDebug &operator<<(std::nullopt_t) { stream->ts << "nullopt"; return maybeSpace(); } inline QDebug &operator<<(QTextStreamFunction f) { stream->ts << f; return *this; @@ -361,6 +362,17 @@ inline QDebugIfHasDebugStreamContainer<QMultiHash<Key, T>, Key, T> operator<<(QD return QtPrivate::printAssociativeContainer(debug, "QMultiHash", hash); } +template <class T> +inline QDebugIfHasDebugStream<T> operator<<(QDebug debug, const std::optional<T> &opt) +{ + const QDebugStateSaver saver(debug); + if (!opt) + debug.nospace() << std::nullopt; + else + debug.nospace() << "std::optional(" << *opt << ')'; + return debug; +} + template <class T1, class T2> inline QDebugIfHasDebugStream<T1, T2> operator<<(QDebug debug, const std::pair<T1, T2> &pair) { |
