title: Is there a more efficient way to set a std::vector from a stream?
body: <p>Presently, I set the value of a <code>std::vector&lt;char&gt;</code> from an <code>std::ostringstream</code> as follows:</p>
  
  <pre><code>void
  foo(std::vector&lt;char&gt; &amp;data, std::stringstream &amp;stream) {
    data = std::vector&lt;char&gt;(stream.str().begin(), stream.str().end());
  }
  </code></pre>
  
  <p>I'm wondering if there is a more efficient way to do this with STL in C++ or whether the method I give here is considered appropriate?  Would I be better off using <code>std::stringstream</code> instead?</p>