title: Lifetime management of std::string when used in asynchronous boost.asio operation
body: <p>Usually I use <a href="https://stackoverflow.com/a/5345349/487356">this</a> technique using shared pointers for managing the lifetime of my buffers used in asynchronous operations with boost.asio.</p>
  
  <p>What if my buffer is a <code>std::string</code> object (which I guess is a little bit special because it does some internal reference counting or so)? Do I still need a shared pointer of a string object which I pass to the handler of the asynchronous operation? Or is the following safe? (And why / why not ?)</p>
  
  <pre><code>void handler()
  {
  }
  
  void func()
  {
      std::ostringstream stringbuilder;
      // fill stringbuilder
  
      socket.async_send(boost::asio::buffer(stringbuilder.str()), boost:bind(handler));
  }
  </code></pre>