simple_example_5.cpp 985 B

12345678910111213141516171819202122232425262728293031323334
  1. // (c) Copyright John R. Bandela 2001.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/tokenizer for documenation
  6. /// simple_example_5.cpp
  7. #include<iostream>
  8. #include<boost/token_iterator.hpp>
  9. #include<string>
  10. #ifdef __BORLANDC__
  11. // compiler bug fix:
  12. template class boost::token_iterator_generator<boost::offset_separator>::type;
  13. #endif
  14. int main(){
  15. using namespace std;
  16. using namespace boost;
  17. string s = "12252001";
  18. int offsets[] = {2,2,4};
  19. offset_separator f(offsets, offsets+3);
  20. typedef token_iterator_generator<offset_separator>::type Iter;
  21. Iter beg = make_token_iterator<string>(s.begin(),s.end(),f);
  22. Iter end = make_token_iterator<string>(s.end(),s.end(),f);
  23. // The above statement could also have been what is below
  24. // Iter end;
  25. for(;beg!=end;++beg){
  26. cout << *beg << "\n";
  27. }
  28. return 0;
  29. }