Add C++11-style cbegin, cend, etc. to wxString's iterator interface

These c-prefixed functions always return a const_iterator.
The full list of functions added: cbegin(), cend(), crbegin(), crend().

Closes https://github.com/wxWidgets/wxWidgets/pull/314
This commit is contained in:
Lauri Nurmi
2016-08-24 19:02:12 +03:00
committed by Vadim Zeitlin
parent e68bd5a319
commit 394ce5f631
3 changed files with 11 additions and 0 deletions

View File

@@ -1282,20 +1282,26 @@ public:
// first valid index position
const_iterator begin() const { return const_iterator(this, m_impl.begin()); }
iterator begin() { return iterator(this, m_impl.begin()); }
const_iterator cbegin() const { return const_iterator(this, m_impl.begin()); }
// position one after the last valid one
const_iterator end() const { return const_iterator(this, m_impl.end()); }
iterator end() { return iterator(this, m_impl.end()); }
const_iterator cend() const { return const_iterator(this, m_impl.end()); }
// first element of the reversed string
const_reverse_iterator rbegin() const
{ return const_reverse_iterator(end()); }
reverse_iterator rbegin()
{ return reverse_iterator(end()); }
const_reverse_iterator crbegin() const
{ return const_reverse_iterator(end()); }
// one beyond the end of the reversed string
const_reverse_iterator rend() const
{ return const_reverse_iterator(begin()); }
reverse_iterator rend()
{ return reverse_iterator(begin()); }
const_reverse_iterator crend() const
{ return const_reverse_iterator(begin()); }
// std::string methods:
#if wxUSE_UNICODE_UTF8