summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstring.h
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-02-23 10:39:15 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2022-03-04 01:58:10 +0100
commite440fec7fc729342dce7c8421618a95dab11a36b (patch)
tree64e2bc568b0da05adb69d84850bb0761105738b1 /src/corelib/text/qstring.h
parentd45d62f09dd276faf3d960d18aba191e4c3c78ba (diff)
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 <andrei.golubev@qt.io>
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r--src/corelib/text/qstring.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 350659ed46..c8c25da3cc 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -1589,6 +1589,19 @@ inline QString operator"" _qs(const char16_t *str, size_t size) noexcept
}
} // QtLiterals
+namespace Qt {
+inline namespace Literals {
+inline namespace StringLiterals {
+
+constexpr inline QLatin1String operator"" _L1(const char *str, size_t size) noexcept
+{
+ return QLatin1String(str, qsizetype(size));
+}
+
+} // StringLiterals
+} // Literals
+} // Qt
+
QT_END_NAMESPACE
#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER)