From 4f450ddf1965a5d6220ba1460ae4514a4cad63b6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 8 Sep 2023 17:17:17 +0200 Subject: [PATCH] Qt UDLs: avoid the deprecated form of UDL definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cppreference.com says¹ that the space after the "" is deprecated now, so remove the space. Let's just hope all our compilers support this, otherwise it will get ugly². ¹ https://en.cppreference.com/w/cpp/language/user_literal#Literal_operators ² https://github.com/yhirose/cpp-httplib/issues/953 Pick-to: 6.5 6.2 Change-Id: Ic8e4939e3ba713023c5a5c020305c96b521dbda9 Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira (cherry picked from commit 5503b478935aee563d31c5df035803818f4cead3) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qbytearray.h | 4 ++-- src/corelib/text/qchar.h | 2 +- src/corelib/text/qlatin1stringview.h | 2 +- src/corelib/text/qstring.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 972e2174d3f..3b99ef78b27 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -715,7 +715,7 @@ namespace Qt { inline namespace Literals { inline namespace StringLiterals { -inline QByteArray operator"" _ba(const char *str, size_t size) noexcept +inline QByteArray operator""_ba(const char *str, size_t size) noexcept { return QByteArray(QByteArrayData(nullptr, const_cast(str), qsizetype(size))); } @@ -728,7 +728,7 @@ inline namespace QtLiterals { #if QT_DEPRECATED_SINCE(6, 8) QT_DEPRECATED_VERSION_X_6_8("Use _ba from Qt::StringLiterals namespace instead.") -inline QByteArray operator"" _qba(const char *str, size_t size) noexcept +inline QByteArray operator""_qba(const char *str, size_t size) noexcept { return Qt::StringLiterals::operator""_ba(str, size); } diff --git a/src/corelib/text/qchar.h b/src/corelib/text/qchar.h index e9f0cf3346c..30a15f96a28 100644 --- a/src/corelib/text/qchar.h +++ b/src/corelib/text/qchar.h @@ -627,7 +627,7 @@ namespace Qt { inline namespace Literals { inline namespace StringLiterals { -constexpr inline QLatin1Char operator"" _L1(char ch) noexcept +constexpr inline QLatin1Char operator""_L1(char ch) noexcept { return QLatin1Char(ch); } diff --git a/src/corelib/text/qlatin1stringview.h b/src/corelib/text/qlatin1stringview.h index 257e7b30065..4a7bf357ed3 100644 --- a/src/corelib/text/qlatin1stringview.h +++ b/src/corelib/text/qlatin1stringview.h @@ -352,7 +352,7 @@ namespace Qt { inline namespace Literals { inline namespace StringLiterals { -constexpr inline QLatin1StringView operator"" _L1(const char *str, size_t size) noexcept +constexpr inline QLatin1StringView operator""_L1(const char *str, size_t size) noexcept { return {str, qsizetype(size)}; } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index b67ed099de0..c00885dab25 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1470,7 +1470,7 @@ qsizetype erase_if(QString &s, Predicate pred) namespace Qt { inline namespace Literals { inline namespace StringLiterals { -inline QString operator"" _s(const char16_t *str, size_t size) noexcept +inline QString operator""_s(const char16_t *str, size_t size) noexcept { return QString(QStringPrivate(nullptr, const_cast(str), qsizetype(size))); } @@ -1483,7 +1483,7 @@ inline namespace QtLiterals { #if QT_DEPRECATED_SINCE(6, 8) QT_DEPRECATED_VERSION_X_6_8("Use _s from Qt::StringLiterals namespace instead.") -inline QString operator"" _qs(const char16_t *str, size_t size) noexcept +inline QString operator""_qs(const char16_t *str, size_t size) noexcept { return Qt::StringLiterals::operator""_s(str, size); }