Slight code cleanup in utf8_iterator.hh
This commit is contained in:
parent
a39f2b0c71
commit
2f7313ad59
|
@ -13,7 +13,7 @@ namespace utf8
|
||||||
|
|
||||||
// adapter for an iterator on bytes which permits to iterate
|
// adapter for an iterator on bytes which permits to iterate
|
||||||
// on unicode codepoints instead.
|
// on unicode codepoints instead.
|
||||||
template<typename Iterator,
|
template<typename BaseIt,
|
||||||
typename CodepointType = Codepoint,
|
typename CodepointType = Codepoint,
|
||||||
typename DifferenceType = CharCount,
|
typename DifferenceType = CharCount,
|
||||||
typename InvalidPolicy = utf8::InvalidPolicy::Pass>
|
typename InvalidPolicy = utf8::InvalidPolicy::Pass>
|
||||||
|
@ -23,12 +23,12 @@ class iterator : public std::iterator<std::bidirectional_iterator_tag,
|
||||||
public:
|
public:
|
||||||
iterator() = default;
|
iterator() = default;
|
||||||
|
|
||||||
iterator(Iterator it, Iterator begin, Iterator end)
|
iterator(BaseIt it, BaseIt begin, BaseIt 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)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
iterator(Iterator it, const Container& c)
|
iterator(BaseIt it, const Container& c)
|
||||||
: m_it{std::move(it)}, m_begin{std::begin(c)}, m_end{std::end(c)}
|
: m_it{std::move(it)}, m_begin{std::begin(c)}, m_end{std::end(c)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -91,14 +91,14 @@ public:
|
||||||
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) { return m_it == other; }
|
bool operator==(const BaseIt& other) { return m_it == other; }
|
||||||
bool operator!=(const Iterator& other) { return m_it != other; }
|
bool operator!=(const BaseIt& other) { return m_it != other; }
|
||||||
|
|
||||||
bool operator< (const Iterator& other) const { return m_it < other; }
|
bool operator< (const BaseIt& other) const { return m_it < other; }
|
||||||
bool operator<= (const Iterator& other) const { return m_it <= other; }
|
bool operator<= (const BaseIt& other) const { return m_it <= other; }
|
||||||
|
|
||||||
bool operator> (const Iterator& other) const { return m_it > other; }
|
bool operator> (const BaseIt& other) const { return m_it > other; }
|
||||||
bool operator>= (const Iterator& other) const { return m_it >= other; }
|
bool operator>= (const BaseIt& other) const { return m_it >= other; }
|
||||||
|
|
||||||
DifferenceType operator-(const iterator& other) const
|
DifferenceType operator-(const iterator& other) const
|
||||||
{
|
{
|
||||||
|
@ -110,8 +110,7 @@ public:
|
||||||
return get_value();
|
return get_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Iterator& base() const { return m_it; }
|
const BaseIt& base() const { return m_it; }
|
||||||
Iterator& base() { return m_it; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void invalidate_value() { m_value = -1; }
|
void invalidate_value() { m_value = -1; }
|
||||||
|
@ -122,9 +121,9 @@ private:
|
||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator m_it;
|
BaseIt m_it;
|
||||||
Iterator m_begin;
|
BaseIt m_begin;
|
||||||
Iterator m_end;
|
BaseIt m_end;
|
||||||
mutable CodepointType m_value = -1;
|
mutable CodepointType m_value = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user