container_source_example.cpp 824 B

1234567891011121314151617181920212223242526
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2005-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5. // See http://www.boost.org/libs/iostreams for documentation.
  6. #include <cassert>
  7. #include <string>
  8. #include <boost/iostreams/stream.hpp>
  9. #include <libs/iostreams/example/container_device.hpp>
  10. namespace io = boost::iostreams;
  11. namespace ex = boost::iostreams::example;
  12. int main()
  13. {
  14. using namespace std;
  15. typedef ex::container_source<string> string_source;
  16. string input = "Hello World!";
  17. string output;
  18. io::stream<string_source> in(input);
  19. getline(in, output);
  20. assert(input == output);
  21. }