summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-12-09 10:52:31 -0800
committerThiago Macieira <thiago.macieira@intel.com>2020-12-12 12:17:18 -0800
commit4974091699795435c4863ce57e6513312ddb1f1d (patch)
tree09e0d803e8250c59832177eefed29e23bf994933 /src/corelib
parentf3cfdb905b926948659f37924837b3c14868ff6a (diff)
QStringView: add constBegin and constEnd
Change-Id: I55083c2909f64a1f8868fffd164f21118a9d3ec5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qstringview.cpp25
-rw-r--r--src/corelib/text/qstringview.h2
2 files changed, 23 insertions, 4 deletions
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp
index b64d128a65..1c3249fbfb 100644
--- a/src/corelib/text/qstringview.cpp
+++ b/src/corelib/text/qstringview.cpp
@@ -395,7 +395,7 @@ QT_BEGIN_NAMESPACE
This function is provided for STL compatibility.
- \sa end(), cbegin(), rbegin(), data()
+ \sa end(), constBegin(), cbegin(), rbegin(), data()
*/
/*!
@@ -405,7 +405,16 @@ QT_BEGIN_NAMESPACE
This function is provided for STL compatibility.
- \sa cend(), begin(), crbegin(), data()
+ \sa cend(), begin(), constBegin(), crbegin(), data()
+*/
+
+/*!
+ \fn QStringView::const_iterator QStringView::constBegin() const
+ \since 6.1
+
+ Same as begin().
+
+ \sa constEnd(), begin(), cbegin(), crbegin(), data()
*/
/*!
@@ -416,7 +425,7 @@ QT_BEGIN_NAMESPACE
This function is provided for STL compatibility.
- \sa begin(), cend(), rend()
+ \sa begin(), constEnd(), cend(), rend()
*/
/*! \fn QStringView::const_iterator QStringView::cend() const
@@ -425,7 +434,15 @@ QT_BEGIN_NAMESPACE
This function is provided for STL compatibility.
- \sa cbegin(), end(), crend()
+ \sa cbegin(), end(), constEnd(), crend()
+*/
+
+/*! \fn QStringView::const_iterator QStringView::constEnd() const
+ \since 6.1
+
+ Same as end().
+
+ \sa constBegin(), end(), cend(), crend()
*/
/*!
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h
index 42935440f3..fef2ffde7b 100644
--- a/src/corelib/text/qstringview.h
+++ b/src/corelib/text/qstringview.h
@@ -442,6 +442,8 @@ public:
//
// Qt compatibility API:
//
+ [[nodiscard]] const_iterator constBegin() const noexcept { return begin(); }
+ [[nodiscard]] const_iterator constEnd() const noexcept { return end(); }
[[nodiscard]] constexpr bool isNull() const noexcept { return !m_data; }
[[nodiscard]] constexpr bool isEmpty() const noexcept { return empty(); }
[[nodiscard]] constexpr int length() const /* not nothrow! */