Fix comparison operators in utf8_iterator and tag it as bidirectional

This commit is contained in:
Maxime Coste 2016-04-22 20:43:29 +01:00
parent d5a8d9bf3a
commit 21644d17d6

View File

@ -15,10 +15,12 @@ namespace utf8
// on unicode codepoints instead. // on unicode codepoints instead.
template<typename Iterator, template<typename Iterator,
typename InvalidPolicy = utf8::InvalidPolicy::Pass> typename InvalidPolicy = utf8::InvalidPolicy::Pass>
class iterator : public std::iterator<std::forward_iterator_tag, class iterator : public std::iterator<std::bidirectional_iterator_tag,
Codepoint, CharCount> Codepoint, CharCount>
{ {
public: public:
iterator() = default;
iterator(Iterator it, Iterator begin, Iterator end) iterator(Iterator it, Iterator begin, Iterator end)
: m_it{std::move(it)}, m_begin{std::move(begin)}, m_end{std::move(end)} : m_it{std::move(it)}, m_begin{std::move(begin)}, m_end{std::move(end)}
{} {}
@ -78,8 +80,8 @@ public:
return res; return res;
} }
bool operator==(const iterator& other) { return m_it == other.m_it; } bool operator==(const iterator& other) const { return m_it == other.m_it; }
bool operator!=(const iterator& other) { return m_it != other.m_it; } bool operator!=(const iterator& other) const { return m_it != other.m_it; }
bool operator< (const iterator& other) const { return m_it < other.m_it; } bool operator< (const iterator& other) const { return m_it < other.m_it; }
bool operator<= (const iterator& other) const { return m_it <= other.m_it; } bool operator<= (const iterator& other) const { return m_it <= other.m_it; }