Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Class template find_iterator

boost::algorithm::find_iterator — find_iterator


// In header: <boost/algorithm/string/find_iterator.hpp>

template<typename IteratorT> 
class find_iterator : public iterator_facade< find_iterator< IteratorT >, const iterator_range< IteratorT >, forward_traversal_tag >
  // construct/copy/destruct
  find_iterator(const find_iterator &);
  template<typename FinderT, typename RangeT> find_iterator(RangeT &, FinderT);

  // public member functions
   BOOST_DEFAULTED_FUNCTION(find_iterator & = (const find_iterator &Other), 
                            { if(this==&Other) return *this;this->base_type::operator=(Other);m_Match=Other.m_Match;m_End=Other.m_End;return *this;});
  IteratorT FinderT m_Match(Begin, Begin);
  IteratorT FinderT m_End(End);
  bool eof() const;

  // private member functions
  const match_type & dereference() const;
  void increment();
  bool equal(const find_iterator &) const;

  // public data members
  IteratorT End;
  IteratorT FinderT Finder;


Find iterator encapsulates a Finder and allows for incremental searching in a string. Each increment moves the iterator to the next match.

Find iterator is a readable forward traversal iterator.

Dereferencing the iterator yields an iterator_range delimiting the current match.

find_iterator public construct/copy/destruct

  1. find_iterator(const find_iterator & Other);
    Default constructor.

    Construct null iterator. All null iterators are equal.

    Construct a copy of the find_iterator


    eof()==true Copy constructor

  2. template<typename FinderT, typename RangeT> 
      find_iterator(RangeT & Col, FinderT Finder);

    Construct new find_iterator for a given finder and a range.

find_iterator public member functions

  1.  BOOST_DEFAULTED_FUNCTION(find_iterator & operator = (const find_iterator &Other), 
                              { if(this==&Other) return *this;this->base_type::operator=(Other);m_Match=Other.m_Match;m_End=Other.m_End;return *this;});
    Copy assignment.

    Assigns a copy of the find_iterator Constructor

    Construct new find_iterator for a given finder and a range.

  2. IteratorT FinderT m_Match(Begin, Begin);
  3. IteratorT FinderT m_End(End);
  4. bool eof() const;
    Eof check.

    Check the eof condition. Eof condition means that there is nothing more to be searched i.e. find_iterator is after the last match.

find_iterator private member functions

  1. const match_type & dereference() const;
  2. void increment();
  3. bool equal(const find_iterator & Other) const;