Add missing operator+= and -= on utf8_iterator

Fix operator== and != that were non-const as well.
This commit is contained in:
Maxime Coste 2017-09-25 22:23:50 +09:00
parent cbb6e9ea0f
commit 18705a0097

View File

@ -63,26 +63,38 @@ public:
iterator operator+(DifferenceType count) const noexcept
{
if (count < 0)
return operator-(-count);
iterator res = *this;
while (count--)
++res;
res += count;
return res;
}
iterator& operator+=(DifferenceType count) noexcept
{
if (count < 0)
return operator-=(-count);
while (count--)
operator++();
return *this;
}
iterator operator-(DifferenceType count) const noexcept
{
if (count < 0)
return operator+(-count);
iterator res = *this;
while (count--)
--res;
res -= count;
return res;
}
iterator& operator-=(DifferenceType count) noexcept
{
if (count < 0)
return operator+=(-count);
while (count--)
operator--();
return *this;
}
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; }
@ -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; }