istreambuf_test.cpp 770 B

123456789101112131415161718192021222324252627282930
  1. // istreambuf_test - test lambda function objects with istreambuf_iterator
  2. //
  3. // Copyright (c) 2007 Peter Dimov
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt
  8. #include <boost/lambda/lambda.hpp>
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <iterator>
  11. #include <sstream>
  12. #include <algorithm>
  13. int main()
  14. {
  15. using namespace boost::lambda;
  16. std::stringstream is( "ax2" );
  17. std::istreambuf_iterator<char> b2( is );
  18. std::istreambuf_iterator<char> e2;
  19. std::istreambuf_iterator<char> i = std::find_if( b2, e2, _1 == 'x' );
  20. BOOST_TEST( *i == 'x' );
  21. BOOST_TEST( std::distance( i, e2 ) == 2 );
  22. return boost::report_errors();
  23. }