Add QJsonArray::cbegin()/cend() methods

Add those to be consistent with the rest of Qt and the STL.

Fixes: QTBUG-32793
Change-Id: Ib712b7b16b8be6627aeac79b90c6e9cdf92b60e0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2019-01-23 11:36:25 +01:00
parent ac00b5155e
commit c2b4e7a215
2 changed files with 18 additions and 0 deletions

View File

@ -675,6 +675,14 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
\sa begin(), constEnd()
*/
/*! \fn QJsonArray::const_iterator QJsonArray::cbegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the array.
\sa begin(), cend()
*/
/*! \fn QJsonArray::iterator QJsonArray::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
@ -696,6 +704,14 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
\sa constBegin(), end()
*/
/*! \fn QJsonArray::const_iterator QJsonArray::cend() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the array.
\sa cbegin(), end()
*/
/*! \fn void QJsonArray::push_back(const QJsonValue &value)
This function is provided for STL compatibility. It is equivalent

View File

@ -214,9 +214,11 @@ public:
inline iterator begin() { detach2(); return iterator(this, 0); }
inline const_iterator begin() const { return const_iterator(this, 0); }
inline const_iterator constBegin() const { return const_iterator(this, 0); }
inline const_iterator cbegin() const { return const_iterator(this, 0); }
inline iterator end() { detach2(); return iterator(this, size()); }
inline const_iterator end() const { return const_iterator(this, size()); }
inline const_iterator constEnd() const { return const_iterator(this, size()); }
inline const_iterator cend() const { return const_iterator(this, size()); }
iterator insert(iterator before, const QJsonValue &value) { insert(before.i, value); return before; }
iterator erase(iterator it) { removeAt(it.i); return it; }