summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/text/qbytearray.cpp15
-rw-r--r--src/corelib/text/qbytearray.h1
-rw-r--r--src/corelib/text/qstring.cpp18
-rw-r--r--src/corelib/text/qstring.h1
4 files changed, 34 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index a696cb8dbb5..55c622b6cb1 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1271,6 +1271,21 @@ QByteArray::iterator QByteArray::erase(QByteArray::const_iterator first, QByteAr
return begin() + start;
}
+/*!
+ \fn QByteArray::iterator QByteArray::erase(QByteArray::const_iterator it)
+
+ \since 6.5
+
+ Removes the character denoted by \c it from the byte array.
+ Returns an iterator to the character immediately after the
+ erased character.
+
+ \code
+ QByteArray ba = "abcdefg";
+ auto it = ba.erase(ba.cbegin()); // ba is now "bcdefg" and it points to "b"
+ \endcode
+*/
+
/*! \fn QByteArray::QByteArray(const QByteArray &other)
Constructs a copy of \a other.
diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h
index 1079555c84c..17fd0f20509 100644
--- a/src/corelib/text/qbytearray.h
+++ b/src/corelib/text/qbytearray.h
@@ -429,6 +429,7 @@ public:
{ prepend(a); }
void shrink_to_fit() { squeeze(); }
iterator erase(const_iterator first, const_iterator last);
+ inline iterator erase(const_iterator it) { return erase(it, it + 1); }
static QByteArray fromStdString(const std::string &s);
std::string toStdString() const;
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 43b64f399e9..4d7522a2b85 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -8935,7 +8935,8 @@ bool QString::isRightToLeft() const
Removes from the string 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.
+ immediately after the last erased character (i.e. the character
+ referred to by \a last before the erase).
*/
QString::iterator QString::erase(QString::const_iterator first, QString::const_iterator last)
{
@@ -8945,6 +8946,21 @@ QString::iterator QString::erase(QString::const_iterator first, QString::const_i
return begin() + start;
}
+/*!
+ \fn QString::iterator QString::erase(QString::const_iterator it)
+
+ \since 6.5
+
+ Removes the character denoted by \c it from the string.
+ Returns an iterator to the character immediately after the
+ erased character.
+
+ \code
+ QString c = "abcdefg";
+ auto it = c.erase(c.cbegin()); // c is now "bcdefg"; "it" points to "b"
+ \endcode
+*/
+
/*! \fn void QString::shrink_to_fit()
\since 5.10
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index d30bc0b8514..9c67558edd8 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -1086,6 +1086,7 @@ public:
inline void push_front(const QString &s) { prepend(s); }
void shrink_to_fit() { squeeze(); }
iterator erase(const_iterator first, const_iterator last);
+ inline iterator erase(const_iterator it) { return erase(it, it + 1); }
static inline QString fromStdString(const std::string &s);
inline std::string toStdString() const;