diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-10-17 02:25:53 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-26 14:43:20 +0100 |
commit | 5771591fbce7d3f4359aea7342d036c8f287bb64 (patch) | |
tree | 0ed31eef86e85e97f0c143ab210585cfe3088e3f /src/corelib/text/qbytearray.cpp | |
parent | b475c3e67e79a1b2231f8139c4956de960d1cb37 (diff) |
QString/QByteArray: add erase() for iterators
Otherwise they're not usable with iterator-based algorithms
that e.g. remove, partition and the like.
[ChangeLog][QtCore][QString] Added erase().
[ChangeLog][QtCore][QByteArray] Added erase().
Change-Id: I78829b1a5365dd53b6b6423ceedbc52edeafbc63
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 4679c5a05d..3845946ce9 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1115,6 +1115,21 @@ QByteArray qUncompress(const uchar* data, qsizetype nbytes) squeeze(). */ +/*! + \since 6.1 + + Removes from the byte array the characters in the half-open range + [ \a first , \a last ). Returns an iterator to the character + referred to by \a last before the erase. +*/ +QByteArray::iterator QByteArray::erase(QByteArray::const_iterator first, QByteArray::const_iterator last) +{ + const auto start = std::distance(cbegin(), first); + const auto len = std::distance(first, last); + remove(start, len); + return begin() + start; +} + /*! \fn QByteArray::QByteArray(const QByteArray &other) Constructs a copy of \a other. |