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

@@ -74,6 +74,7 @@ All:
- Add support for loading dynamic lexer in wxStyledTextCtrl (New Pagodi). - Add support for loading dynamic lexer in wxStyledTextCtrl (New Pagodi).
- Handle strings with embedded NULs in wxDataStream (Nitch). - Handle strings with embedded NULs in wxDataStream (Nitch).
- Don't crash in wxTextFile::GetLastLine() if the file is empty (crohr). - Don't crash in wxTextFile::GetLastLine() if the file is empty (crohr).
- Add wxString::cbegin() and cend() method (Lauri Nurmi).
All (GUI): All (GUI):

View File

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

View File

@@ -1574,13 +1574,17 @@ public:
const_iterator begin() const; const_iterator begin() const;
iterator begin(); iterator begin();
const_iterator cbegin() const;
const_iterator end() const; const_iterator end() const;
iterator end(); iterator end();
const_iterator cend() const;
const_reverse_iterator rbegin() const; const_reverse_iterator rbegin() const;
reverse_iterator rbegin(); reverse_iterator rbegin();
const_reverse_iterator crbegin() const;
const_reverse_iterator rend() const; const_reverse_iterator rend() const;
reverse_iterator rend(); reverse_iterator rend();
const_reverse_iterator crend() const;
//@} //@}