| 77 | |
| 78 | template<bool Const> |
| 79 | struct iterator |
| 80 | : detail::stl_interfaces::proxy_iterator_interface< |
| 81 | iterator<Const>, |
| 82 | std::forward_iterator_tag, |
| 83 | BOOST_PARSER_SUBRANGE< |
| 84 | detail::iterator_t<detail::maybe_const<Const, V>>>> |
| 85 | { |
| 86 | using I = detail::iterator_t<detail::maybe_const<Const, V>>; |
| 87 | using S = detail::sentinel_t<detail::maybe_const<Const, V>>; |
| 88 | |
| 89 | constexpr iterator() = default; |
| 90 | constexpr iterator( |
| 91 | detail::maybe_const<Const, split_view> * parent) : |
| 92 | parent_(parent), |
| 93 | r_(parent_->base_.begin(), parent_->base_.end()), |
| 94 | curr_(r_.begin(), r_.begin()), |
| 95 | next_it_(r_.begin()), |
| 96 | next_follows_match_(false) |
| 97 | { |
| 98 | ++*this; |
| 99 | } |
| 100 | |
| 101 | constexpr iterator & operator++() |
| 102 | { |
| 103 | if (next_it_ == r_.end() && next_follows_match_) { |
| 104 | curr_ = BOOST_PARSER_SUBRANGE(next_it_, next_it_); |
| 105 | next_follows_match_ = false; |
| 106 | return *this; |
| 107 | } |
| 108 | r_ = BOOST_PARSER_SUBRANGE<I, S>(next_it_, r_.end()); |
| 109 | auto const curr_match = parser::search( |
| 110 | r_, parent_->parser_, parent_->skip_, parent_->trace_mode_); |
| 111 | curr_ = BOOST_PARSER_SUBRANGE(next_it_, curr_match.begin()); |
| 112 | next_it_ = curr_match.end(); |
| 113 | next_follows_match_ = !curr_match.empty(); |
| 114 | return *this; |
| 115 | } |
| 116 | |
| 117 | constexpr BOOST_PARSER_SUBRANGE<I> operator*() const |
| 118 | { |
| 119 | return curr_; |
| 120 | } |
| 121 | |
| 122 | friend constexpr bool operator==(iterator lhs, iterator rhs) |
| 123 | { |
| 124 | return lhs.r_.begin() == rhs.r_.begin(); |
| 125 | } |
| 126 | friend constexpr bool operator==(iterator it, sentinel<Const>) |
| 127 | { |
| 128 | return it.r_.begin() == it.r_.end(); |
| 129 | } |
| 130 | |
| 131 | using base_type = detail::stl_interfaces::proxy_iterator_interface< |
| 132 | iterator, |
| 133 | std::forward_iterator_tag, |
| 134 | BOOST_PARSER_SUBRANGE<I>>; |
| 135 | using base_type::operator++; |
| 136 | |