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>
This commit is contained in:
Thiago Macieira 2020-12-09 10:52:31 -08:00
parent f3cfdb905b
commit 4974091699
2 changed files with 23 additions and 4 deletions

View File

@ -395,7 +395,7 @@ QT_BEGIN_NAMESPACE
This function is provided for STL compatibility. 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. 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. This function is provided for STL compatibility.
\sa begin(), cend(), rend() \sa begin(), constEnd(), cend(), rend()
*/ */
/*! \fn QStringView::const_iterator QStringView::cend() const /*! \fn QStringView::const_iterator QStringView::cend() const
@ -425,7 +434,15 @@ QT_BEGIN_NAMESPACE
This function is provided for STL compatibility. 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()
*/ */
/*! /*!

View File

@ -442,6 +442,8 @@ public:
// //
// Qt compatibility API: // 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 isNull() const noexcept { return !m_data; }
[[nodiscard]] constexpr bool isEmpty() const noexcept { return empty(); } [[nodiscard]] constexpr bool isEmpty() const noexcept { return empty(); }
[[nodiscard]] constexpr int length() const /* not nothrow! */ [[nodiscard]] constexpr int length() const /* not nothrow! */