diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 55be6d13a48..ff31806b4cb 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -424,11 +424,10 @@ inline QDebugIfHasDebugStreamContainer, Key, T> operator<<(QD template inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::optional &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; }