title: Reading raw byte array into std::string
body: <p>I've been wondering about the following issue: assume I have a C style function that reads raw data into a buffer</p>
  
  <pre><code>int recv_n(int handle, void* buf, size_t len);
  </code></pre>
  
  <p>Can I read the data directly into an <code>std:string</code> or <code>stringstream</code> without allocating any temporal buffers? For example,</p>
  
  <pre><code>std::string s(100, '\0');
  recv_n(handle, s.data(), 100);
  </code></pre>
  
  <p>I guess this solution has an undefined outcome, because, afaik, <code>string::c_str</code> and <code>string::data</code> might return a temporal location and not necessarily return the pointer to the real place in the memory, used by the object to store the data.</p>
  
  <p>Any ideas?</p>