summaryrefslogtreecommitdiff
path: root/src/utf8_iterator.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/utf8_iterator.hh')
-rw-r--r--src/utf8_iterator.hh32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/utf8_iterator.hh b/src/utf8_iterator.hh
index 20dc0b83..b2563e43 100644
--- a/src/utf8_iterator.hh
+++ b/src/utf8_iterator.hh
@@ -63,24 +63,36 @@ public:
iterator operator+(DifferenceType count) const noexcept
{
+ iterator res = *this;
+ res += count;
+ return res;
+ }
+
+ iterator& operator+=(DifferenceType count) noexcept
+ {
if (count < 0)
- return operator-(-count);
+ return operator-=(-count);
- iterator res = *this;
while (count--)
- ++res;
- return res;
+ operator++();
+ return *this;
}
iterator operator-(DifferenceType count) const noexcept
{
+ iterator res = *this;
+ res -= count;
+ return res;
+ }
+
+ iterator& operator-=(DifferenceType count) noexcept
+ {
if (count < 0)
- return operator+(-count);
+ return operator+=(-count);
- iterator res = *this;
while (count--)
- --res;
- return res;
+ operator--();
+ return *this;
}
bool operator==(const iterator& other) const noexcept { return m_it == other.m_it; }
@@ -92,8 +104,8 @@ public:
bool operator> (const iterator& other) const noexcept { return m_it > other.m_it; }
bool operator>= (const iterator& other) const noexcept { return m_it >= other.m_it; }
- bool operator==(const BaseIt& other) noexcept { return m_it == other; }
- bool operator!=(const BaseIt& other) noexcept { return m_it != other; }
+ bool operator==(const BaseIt& other) const noexcept { return m_it == other; }
+ bool operator!=(const BaseIt& other) const noexcept { return m_it != other; }
bool operator< (const BaseIt& other) const noexcept { return m_it < other; }
bool operator<= (const BaseIt& other) const noexcept { return m_it <= other; }