summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdebug.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2024-10-21 15:01:13 +0200
committerMarc Mutz <marc.mutz@qt.io>2024-12-18 07:12:02 +0000
commit08320bfe2b7387d6f488d405dddf9d3aba6434ec (patch)
tree0888fbd48f8eba435a7060bc7dc3b08e4ad7a309 /src/corelib/io/qdebug.cpp
parentec011141b8d17a2edc58e0d5b6ebb0f1632fff90 (diff)
QDebug: make std::optional stream operator SCARY
Piggy-back on the recently-added, type-erased, std::tuple stream operator to handle std::optional the same way. While std::optional doesn't support the Tuple Protocol, and we therefore can't use putTuple() directly, we can still use putTupleImplImpl() if we set up its arguments manually. [ChangeLog][Potentially Source-Incompatible Changes][QDebug] The std::optional streaming operator is now a member of QDebug, not a free function. This breaks users that rely on the exact definition of the operator (e.g. `operator<<(d, opt)`). A backwards-compatible fix is to call the operator with infix notation (d << opt) only, and to avoid const QDebug objects. Pick-to: 6.9 Change-Id: Ib040d65953ca9d3892aee5bdb597d6d30a9694b1 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/io/qdebug.cpp')
-rw-r--r--src/corelib/io/qdebug.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 1fb2addc9ed..fc70e066f78 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -1258,10 +1258,9 @@ QDebug &QDebug::putTupleLikeImplImpl(const char *ns, const char *what,
/*!
\since 6.7
- \fn template <class T> QDebug operator<<(QDebug debug, const std::optional<T> &opt)
- \relates QDebug
+ \fn template <class T, QDebug::if_streamable<T>> QDebug::operator<<(const std::optional<T> &opt)
- Writes the contents of \a opt (or \c nullopt if not set) to \a debug.
+ Writes the contents of \a opt (or \c nullopt if not set) to this stream.
\c T needs to support streaming into QDebug.
*/