char_sep_example_3.cpp 711 B

1234567891011121314151617181920212223242526
  1. // (c) Copyright Jeremy Siek 2002.
  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. // Sample output:
  6. // <This> <is> <,> <a> <test>
  7. // char_sep_example_3.cpp
  8. #include <iostream>
  9. #include <boost/tokenizer.hpp>
  10. #include <string>
  11. int main()
  12. {
  13. std::string str = "This is, a test";
  14. typedef boost::tokenizer<boost::char_separator<char> > Tok;
  15. boost::char_separator<char> sep; // default constructed
  16. Tok tok(str, sep);
  17. for(Tok::iterator tok_iter = tok.begin(); tok_iter != tok.end(); ++tok_iter)
  18. std::cout << "<" << *tok_iter << "> ";
  19. std::cout << "\n";
  20. return EXIT_SUCCESS;
  21. }