container_sink_example.cpp 791 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_sink<string> string_sink;
  16. string result;
  17. io::stream<string_sink> out(result);
  18. out << "Hello World!";
  19. out.flush();
  20. assert(result == "Hello World!");
  21. }