| 367 | |
| 368 | template<bool Const> |
| 369 | struct iterator |
| 370 | : detail::stl_interfaces::proxy_iterator_interface< |
| 371 | iterator<Const>, |
| 372 | std::forward_iterator_tag, |
| 373 | BOOST_PARSER_SUBRANGE< |
| 374 | detail::iterator_t<detail::maybe_const<Const, V>>>> |
| 375 | { |
| 376 | using I = detail::iterator_t<detail::maybe_const<Const, V>>; |
| 377 | using S = detail::sentinel_t<detail::maybe_const<Const, V>>; |
| 378 | |
| 379 | constexpr iterator() = default; |
| 380 | constexpr iterator( |
| 381 | detail::maybe_const<Const, search_all_view> * parent) : |
| 382 | parent_(parent), |
| 383 | r_(parent_->base_.begin(), parent_->base_.end()), |
| 384 | curr_(r_.begin(), r_.begin()), |
| 385 | next_it_(r_.begin()) |
| 386 | { |
| 387 | ++*this; |
| 388 | } |
| 389 | |
| 390 | constexpr iterator & operator++() |
| 391 | { |
| 392 | r_ = BOOST_PARSER_SUBRANGE<I, S>(next_it_, r_.end()); |
| 393 | curr_ = parser::search( |
| 394 | r_, parent_->parser_, parent_->skip_, parent_->trace_mode_); |
| 395 | next_it_ = curr_.end(); |
| 396 | if (curr_.begin() == curr_.end()) |
| 397 | r_ = BOOST_PARSER_SUBRANGE<I, S>(next_it_, r_.end()); |
| 398 | return *this; |
| 399 | } |
| 400 | |
| 401 | constexpr BOOST_PARSER_SUBRANGE<I> operator*() const |
| 402 | { |
| 403 | return curr_; |
| 404 | } |
| 405 | |
| 406 | friend constexpr bool operator==(iterator lhs, iterator rhs) |
| 407 | { |
| 408 | return lhs.r_.begin() == rhs.r_.begin(); |
| 409 | } |
| 410 | friend constexpr bool operator==(iterator it, sentinel<Const>) |
| 411 | { |
| 412 | return it.r_.begin() == it.r_.end(); |
| 413 | } |
| 414 | |
| 415 | using base_type = detail::stl_interfaces::proxy_iterator_interface< |
| 416 | iterator, |
| 417 | std::forward_iterator_tag, |
| 418 | BOOST_PARSER_SUBRANGE<I>>; |
| 419 | using base_type::operator++; |
| 420 | |
| 421 | private: |
| 422 | detail::maybe_const<Const, search_all_view> * parent_; |
| 423 | BOOST_PARSER_SUBRANGE<I, S> r_; |
| 424 | BOOST_PARSER_SUBRANGE<I> curr_; |
| 425 | I next_it_; |
| 426 | }; |