title: Writing a memory buffer to std::stringstream
body: <p>I have a class that represents a buffer in memory</p>
  
  <pre><code>class Buffer
  {
  public:
      Buffer(const char* buffer, size_t size)
          :m_buffer(buffer), m_size(size)
      {
      }
  
      const char* m_buffer;
      size_t m_size;
  };
  </code></pre>
  
  <p>I need to overload <code>operator&lt;&lt;</code> on this class so that it can be written to a <code>std::stringstream</code> like this</p>
  
  <pre><code>char arr[] = "hello world";
  Buffer buf(arr, 11);
  std::stringstream ss;
  ss &lt;&lt; buf;
  </code></pre>
  
  <p>How do I do this? Note that the memory buffer might have <code>NULL</code> chars in between. Also, since the memory buffer can be large, I want to avoid making any extra copies of this (other than the copy into the stringstream).</p>