From e440fec7fc729342dce7c8421618a95dab11a36b Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 23 Feb 2022 10:39:15 +0100 Subject: Add literal operators for QLatin1String and QLatin1Char The operators are declared in the Qt::Literals::StringLiterals namespace, to avoid collisions in the global namespace. [ChangeLog][QtCore][QLatin1String] Added literal operator""_L1 that converts string literals and chars to QLatin1String and QLatin1Char. Fixes: QTBUG-98434 Change-Id: Ia945a6acf4b8d4fbbb5f803264e4d79d7b17a8da Reviewed-by: Andrei Golubev --- src/corelib/text/qstring.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/corelib/text/qstring.cpp') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index ae5f57ce41..9b6fe88cf1 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -10849,6 +10849,25 @@ QString QString::toHtmlEscaped() const \sa QStringLiteral, QtLiterals::operator""_qba(const char *str, size_t size) */ +/*! + \fn Qt::Literals::StringLiterals::operator""_L1(const char *str, size_t size) + + \relates QLatin1String + \since 6.4 + + Literal operator that creates a QLatin1String out of the first \a size + characters in the char string literal \a str. + + The following code creates a QLatin1String: + \code + using namespace Qt::Literals::StringLiterals; + + auto str = "hello"_L1; + \endcode + + \sa Qt::Literals::StringLiterals +*/ + /*! \internal */ -- cgit v1.2.3