fork(3) download
  1. #include <iostream>
  2. #include <boost/asio/streambuf.hpp>
  3. #include <boost/asio/buffer.hpp>
  4.  
  5. int main()
  6. {
  7. /* Convert std::string to boost::asio::streambuf */
  8. boost::asio::streambuf sbuf;
  9. std::iostream os(&sbuf);
  10. std::string message("Teststring");
  11. os << message;
  12.  
  13. /* Convert boost::asio::streambuf to std::string */
  14. std::string str((std::istreambuf_iterator<char>(&sbuf)), std::istreambuf_iterator<char>());
  15.  
  16. std::cout << str << std::endl;
  17. }
  18.  
Success #stdin #stdout 0s 16072KB
stdin
Standard input is empty
stdout
Teststring