summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdebug.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-03-01 14:42:32 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-03-02 06:33:35 +0100
commit52c7f699ac3124889b9c01fbc1fd542e30da6753 (patch)
tree9986c7697a278235502ec929843ee10170955984 /src/corelib/io/qdebug.cpp
parenta84b2e5973ace6327ef38644e023e0f81fad21f4 (diff)
QDebug: fix std::string/view stream operators; add u8 versions
Make them templates, for two reasons: - so they can accept std::pmr types and, in general, any basic_string with custom allocators and char_traits - to break overload ambiguities with the Qt string view types Also, add the missing C++20 char8_t overloads. Also, avoid creation of a QString in the sizeof(wchar_t) == 2 case (Windows). Add a comment to optimize for the sizeof(wchar_t) != 2 case later. Found in API review. Pick-to: 6.5 Change-Id: I30139520f582a38863a0936f8eca4b1ed33e37c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/io/qdebug.cpp')
-rw-r--r--src/corelib/io/qdebug.cpp79
1 files changed, 12 insertions, 67 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 61d67ecee5..baef75b234 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -765,75 +765,20 @@ QDebug &QDebug::resetFormat()
/*!
\since 6.5
- \fn QDebug &QDebug::operator<<(const std::string &s)
+ \fn template <typename Char, typename...Args> QDebug &QDebug::operator<<(const std::basic_string<Char, Args...> &s)
+ \fn template <typename Char, typename...Args> QDebug &QDebug::operator<<(std::basic_string_view<Char, Args...> s)
- Converts \a s to a QUtf8StringView,
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(std::string_view s)
-
- Converts \a s to a QUtf8StringView,
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(const std::wstring &s)
-
- Converts \a s to a QString via QString::fromStdWString(),
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(std::wstring_view s)
-
- Converts \a s to a QString via QString::fromWCharArray(),
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(const std::u16string &s)
-
- Converts \a s to a QStringView,
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(std::u16string_view s)
-
- Converts \a s to a QStringView,
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(const std::u32string &s)
-
- Converts \a s to a QString via QString::fromUcs4(),
- writes the result to the stream and returns
- a reference to the stream.
-*/
-
-/*!
- \since 6.5
- \fn QDebug &QDebug::operator<<(std::u32string_view s)
+ Writes the string or string-view \a s to the stream and returns a reference
+ to the stream.
- Converts \a s to a QString via QString::fromUcs4(),
- writes the result to the stream and returns
- a reference to the stream.
+ These operators only participate in overload resolution if \c Char is one of
+ \list
+ \li char
+ \li char8_t (C++20 only)
+ \li char16_t
+ \li char32_t
+ \li wchar_t
+ \endlist
*/
/*!