| 292 | |
| 293 | template<bool Const> |
| 294 | struct iterator : detail::stl_interfaces::proxy_iterator_interface< |
| 295 | iterator<Const>, |
| 296 | std::forward_iterator_tag, |
| 297 | BOOST_PARSER_SUBRANGE<detail::either_iterator< |
| 298 | detail::maybe_const<Const, V>, |
| 299 | detail::maybe_const<Const, ReplacementV>>>> |
| 300 | { |
| 301 | using I = detail::iterator_t<detail::maybe_const<Const, V>>; |
| 302 | using S = detail::sentinel_t<detail::maybe_const<Const, V>>; |
| 303 | |
| 304 | using ref_t_iter = detail::either_iterator< |
| 305 | detail::maybe_const<Const, V>, |
| 306 | detail::maybe_const<Const, ReplacementV>>; |
| 307 | using reference_type = BOOST_PARSER_SUBRANGE<ref_t_iter>; |
| 308 | |
| 309 | constexpr iterator() = default; |
| 310 | constexpr iterator( |
| 311 | detail::maybe_const<Const, replace_view> * parent) : |
| 312 | parent_(parent), |
| 313 | r_(parent_->base_.begin(), parent_->base_.end()), |
| 314 | curr_(r_.begin(), r_.begin()), |
| 315 | next_it_(r_.begin()), |
| 316 | in_match_(true) |
| 317 | { |
| 318 | ++*this; |
| 319 | } |
| 320 | |
| 321 | constexpr iterator & operator++() |
| 322 | { |
| 323 | if (in_match_) { |
| 324 | r_ = BOOST_PARSER_SUBRANGE<I, S>(next_it_, r_.end()); |
| 325 | auto const new_match = parser::search( |
| 326 | r_, |
| 327 | parent_->parser_, |
| 328 | parent_->skip_, |
| 329 | parent_->trace_mode_); |
| 330 | if (new_match.begin() == curr_.end()) { |
| 331 | curr_ = new_match; |
| 332 | } else { |
| 333 | curr_ = |
| 334 | BOOST_PARSER_SUBRANGE(next_it_, new_match.begin()); |
| 335 | in_match_ = false; |
| 336 | } |
| 337 | next_it_ = new_match.end(); |
| 338 | } else { |
| 339 | if (!curr_.empty()) { |
| 340 | curr_ = BOOST_PARSER_SUBRANGE(curr_.end(), next_it_); |
| 341 | in_match_ = true; |
| 342 | } |
| 343 | if (curr_.empty()) |
| 344 | r_ = BOOST_PARSER_SUBRANGE<I, S>(next_it_, r_.end()); |
| 345 | } |
| 346 | return *this; |
| 347 | } |
| 348 | |
| 349 | constexpr reference_type operator*() const |
| 350 | { |
| 351 | if (in_match_) { |