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 split_iterator

boost::algorithm::split_iterator — split_iterator


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

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

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

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

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


Split iterator encapsulates a Finder and allows for incremental searching in a string. Unlike the find iterator, split iterator iterates through gaps between matches.

Find iterator is a readable forward traversal iterator.

Dereferencing the iterator yields an iterator_range delimiting the current match.

split_iterator public construct/copy/destruct

  1. split_iterator();
    Default constructor.

    Construct null iterator. All null iterators are equal.



  2. split_iterator(const split_iterator & Other);
    Copy constructor.

    Construct a copy of the split_iterator

  3. template<typename FinderT, typename RangeT> 
      split_iterator(RangeT & Col, FinderT Finder);

    Construct new split_iterator for a given finder and a collection.

split_iterator public member functions

  1.  BOOST_DEFAULTED_FUNCTION(split_iterator & operator = (const split_iterator &Other), 
                              { if(this==&Other) return *this;this->base_type::operator=(Other);m_Match=Other.m_Match;m_Next=Other.m_Next;m_End=Other.m_End;m_bEof=Other.m_bEof;return *this;});
    Assignment operator.

    Assigns a copy of the split_iterator Constructor

    Construct new split_iterator for a given finder and a range.

  2. IteratorT FinderT m_Match(Begin, Begin);
  3. IteratorT FinderT m_Next(Begin);
  4. IteratorT FinderT m_End(End);
  5. IteratorT FinderT m_bEof(false);
  6. 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.

split_iterator private member functions

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