diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-26 22:43:05 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-10 22:13:49 +0200 |
commit | c58ca4256d881ffed865602fd3da8efb6ebc9d5f (patch) | |
tree | 2619858d2e21ebee531d8c9e2a7af39e23683fca /src/corelib/text | |
parent | b7d073e9905bf9812ba96cecdcf6871a95517d30 (diff) |
Deprecate QStringViewLiteral
As a macro, we can't directly deprecate it, but need to make it call
something deprecated. That is a new ctor with a new enum type
added. The type might be useful for other such ventures, so put it
into qglobal.h
Remove the QT_NO_UNICODE_LITERAL protection, as it's always false
these days, and QT_UNICODE_LITERAL is unconditionally #defined a 20
lines above.
[ChangeLog][QtCore][QStringView] Deprecated the (undocumented)
QStringViewLiteral macro. Just use u"" or QStringView(u"") instead.
Change-Id: I9141320225037e1bc6b7f920bf01a9d0144fdac2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qstringliteral.h | 7 | ||||
-rw-r--r-- | src/corelib/text/qstringview.h | 7 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 603f19c0b4..2a7e607c63 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -82,11 +82,8 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, sizeof(QStringData)) \ /**/ -#ifndef QT_NO_UNICODE_LITERAL -# ifndef QT_UNICODE_LITERAL -# error "If you change QStringLiteral, please change QStringViewLiteral, too" -# endif -# define QStringViewLiteral(str) QStringView(QT_UNICODE_LITERAL(str)) +#if QT_DEPRECATED_SINCE(5, 14) +# define QStringViewLiteral(str) QStringView(QT_UNICODE_LITERAL(str), QtPrivate::Deprecated) #endif template <int N> diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 0a82ac4201..4ab4d2570f 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -185,6 +185,13 @@ public: template <typename Char> Q_DECL_CONSTEXPR QStringView(const Char *str) noexcept; #else +#if QT_DEPRECATED_SINCE(5, 14) + template <typename Array, if_compatible_array<Array> = true> + QT_DEPRECATED_VERSION_X_5_14(R"(Use u"~~~" or QStringView(u"~~~") instead of QStringViewLiteral("~~~"))") + Q_DECL_CONSTEXPR QStringView(const Array &str, QtPrivate::Deprecated_t) noexcept + : QStringView(str, lengthHelperArray(str)) {} +#endif // QT_DEPRECATED_SINCE + template <typename Array, if_compatible_array<Array> = true> Q_DECL_CONSTEXPR QStringView(const Array &str) noexcept : QStringView(str, lengthHelperArray(str)) {} |