boost_back_inserter_example.cpp 719 B

123456789101112131415161718192021222324
  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/device/back_inserter.hpp>
  9. #include <boost/iostreams/filtering_stream.hpp>
  10. namespace io = boost::iostreams;
  11. int main()
  12. {
  13. using namespace std;
  14. string result;
  15. io::filtering_ostream out(io::back_inserter(result));
  16. out << "Hello World!";
  17. out.flush();
  18. assert(result == "Hello World!");
  19. }