fork(1) download
  1. #include <string>
  2. #include <iostream>
  3. #include <boost/foreach.hpp>
  4.  
  5. template<typename I>
  6. struct subseq {
  7. typedef typename I::iterator iterator;
  8. typedef typename I::const_iterator const_iterator;
  9.  
  10. iterator a, b;
  11.  
  12. subseq(typename I::iterator first, typename I::iterator second) : a(first), b(second) {}
  13.  
  14. iterator begin() const { return a; }
  15. iterator end() const { return b; }
  16. };
  17.  
  18. int main()
  19. {
  20. std::string hello( "Hello, world!" );
  21. subseq<std::string> substr(hello.begin()+1, hello.end());
  22.  
  23. BOOST_FOREACH( char ch, substr )
  24. {
  25. std::cout << ch;
  26. }
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
ello, world!