QDebug: simplify op<<(std::optional)
We don't need to enable nospace() if we stream but a single element
(nullopt). As a consequence, delay construction of the StateSaver
until we have determined that the optional is engaged.
Amends b7657ddccb.
Change-Id: Id974dff078cb989b92f84b63bf14956a2fba32b2
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 25931bf2181706e1cba416b0530f07959182f074)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
bb10
parent
a1dd67ebfc
commit
e5e560c7fd
|
|
@ -392,11 +392,10 @@ inline QDebugIfHasDebugStreamContainer<QMultiHash<Key, T>, Key, T> operator<<(QD
|
|||
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 << std::nullopt;
|
||||
const QDebugStateSaver saver(debug);
|
||||
debug.nospace() << "std::optional(" << *opt << ')';
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue