10 #ifndef slimsig_concat_iterator_h
11 #define slimsig_concat_iterator_h
13 #include <type_traits>
16 template <
typename Iterator,
typename Traits = std::iterator_traits<Iterator>>
18 typename Traits::iterator_category,
19 typename Traits::value_type,
20 typename Traits::difference_type,
21 typename Traits::pointer_type,
22 typename Traits::reference_type
29 using range = std::pair<Iterator, Iterator>;
30 using reference =
typename iterator_traits::reference_type;
31 using pointer =
typename iterator_traits::pointer_type;
34 : m_range1(std::move(first)), m_range2(std::move(second)), m_current(first.first), m_is_first(
true) {};
40 return m_current == m_current;
43 return !(*
this == other);
46 return m_current > other.m_current;
49 return !(*
this < other);
52 return (*
this == other) || (*
this < other);
55 return (*
this == other) || (*
this > other);
60 if (m_is_first && m_current == range1.second) {
61 m_current = range2.first;
73 if (!m_is_first && m_current == range2.first) {
74 m_current = prev(range1.second);
89 auto delta = m_is_first ?
offset - std::distance(m_current, range1.second) : -1;
92 m_current = m_range2.first + delta;
104 auto delta = !m_is_first ?
offset - (std::distance(m_current, range2.first)) : -1;
107 m_current = range1.second - delta;
120 return m_current.operator->();
146 template <
typename T1,
typename T2>
151 template <
typename T1,
typename T2>
concat_iterator< T1, T2 > concat_begin(T1 b1, T1 e1, T2 b2, T2 e2)
concat_iterator< T1, T2 > concat_end(T1 b1, T1 e1, T2 b2, T2 e2)
bool operator!=(const concat_iterator &other) const
reference operator[](size_type offset) const
bool operator==(const concat_iterator &other) const
bool operator>=(const concat_iterator &other) const
concat_iterator operator++(int)
concat_iterator(const concat_iterator &other)=default
concat_iterator operator--(int)
concat_iterator & operator++()
typename iterator_traits::pointer_type pointer
typename iterator_traits::reference_type reference
concat_iterator(range first, range second)
concat_iterator operator+(difference_type offset) const
concat_iterator & operator-=(difference_type offset)
concat_iterator(concat_iterator &&)=default
std::iterator_traits< concat_iterator > iterator_traits
concat_iterator & operator--()
concat_iterator & operator+=(difference_type offset)
concat_iterator & operator=(const concat_iterator &)=default
pointer operator->() const
concat_iterator & operator=(concat_iterator &&)=default
concat_iterator operator-(difference_type offset) const
std::pair< Iterator, Iterator > range
bool operator>(const concat_iterator &other) const
reference operator*() const
bool operator<=(const concat_iterator &other) const