title: asio buffer deep copy
body: <p>I have found the reference semantic of asio's buffer is not convenient in use. It requires user to allocate the data in heap, but for small size data(for example, 100 Byte), allocate on stack and copy it several times(I think the copy times should less than 3 when use asio）will be much faster than invoke a new operation.
  For example:</p>
  
  <pre><code>class MyData {
      std::vector&lt;char&gt; data;
  };
  
  void hander(Request req) {
      MyData d;
      async_write(buffer(d.data)...);
  } // oops, d was destroyed, but the actual write have not execute
  
  // this is ok, but awkward and poor performance if data is very small
  void hander(Request req) {
      shared_ptr&lt;MyData&gt; d(new MyData());
      async_write(buffer(d-&gt;data)...bind(&amp;X::handle_write, this, d);
  }
  void handle_write(shared_ptr&lt;MyData&gt; s) {
  }
  </code></pre>
  
  <p>Why asio have not provide a buffer which can do deep copy? It will save copy time for performance but for application send huge number small data, the performance should be worse</p>
  
  <p>In its doc, connection object has a member used to do holding the data, but for most application, a data member is not enough. A queue need to use when the application can write data in any time(Don't like half-duplex protocol such as HTTP) or else data might be overwrited by next write. So if the queue is Queue, that still need to call new, if the queue is Queue, that still need to copy</p>