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 b7657ddccbe0a5ab1cdfc61ae6b7f0501dbfb24a. 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>
This commit is contained in:
parent
a1dd67ebfc
commit
e5e560c7fd
@ -392,11 +392,10 @@ inline QDebugIfHasDebugStreamContainer<QMultiHash<Key, T>, Key, T> operator<<(QD
|
|||||||
template <class T>
|
template <class T>
|
||||||
inline QDebugIfHasDebugStream<T> operator<<(QDebug debug, const std::optional<T> &opt)
|
inline QDebugIfHasDebugStream<T> operator<<(QDebug debug, const std::optional<T> &opt)
|
||||||
{
|
{
|
||||||
const QDebugStateSaver saver(debug);
|
|
||||||
if (!opt)
|
if (!opt)
|
||||||
debug.nospace() << std::nullopt;
|
return debug << std::nullopt;
|
||||||
else
|
const QDebugStateSaver saver(debug);
|
||||||
debug.nospace() << "std::optional(" << *opt << ')';
|
debug.nospace() << "std::optional(" << *opt << ')';
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user