diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-04-06 22:38:58 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-04-07 11:29:45 +0000 |
commit | 6958e189a3743aae63314acfdc706e2c3283a99b (patch) | |
tree | 4c3bb34409919e2d767c3bdc1d1c9e8fe5d11191 /src/corelib/tools/qstring.h | |
parent | ee0951d69b38f766e67262487be95b88501aa4a5 (diff) |
QStringRef: add missing {c,}r{begin,end}()
Most containers have them in Qt 5.7, so add them
to QStringRef, too.
Brush up the docs, use the const_iterator typedef
in the API, for consistency with QString's docs.
[ChangeLog][QtCore][QStringRef] Added reverse iterators,
rbegin(), rend(), crbegin(), crend().
Change-Id: I3d2884a1b2faae02c610ab3871552b65bc6e2521
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 6676efab41..793a859228 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1360,7 +1360,8 @@ class Q_CORE_EXPORT QStringRef { public: typedef QString::size_type size_type; typedef QString::value_type value_type; - typedef QString::const_iterator const_iterator; + typedef const QChar *const_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef QString::const_pointer const_pointer; typedef QString::const_reference const_reference; @@ -1439,10 +1440,15 @@ public: } inline const QChar *data() const { return unicode(); } inline const QChar *constData() const { return unicode(); } - inline const QChar *begin() const { return unicode(); } - inline const QChar *cbegin() const { return unicode(); } - inline const QChar *end() const { return unicode() + size(); } - inline const QChar *cend() const { return unicode() + size(); } + + inline const_iterator begin() const { return unicode(); } + inline const_iterator cbegin() const { return unicode(); } + inline const_iterator end() const { return unicode() + size(); } + inline const_iterator cend() const { return unicode() + size(); } + inline const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + inline const_reverse_iterator crbegin() const { return rbegin(); } + inline const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + inline const_reverse_iterator crend() const { return rend(); } #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED QByteArray toAscii() const Q_REQUIRED_RESULT |