title: stringstream::str copy lifetime
body: <p>Something a lot of C++ programmers miss (read: me) when first using <code>stringstream</code>s is the fact that the copy returned by <code>stringstream::str()</code> is a temporary, which lasts until the end of the expression it's used in. However, I don't understand:</p>
  
  <ol>
  <li>How this is done. Looking in the <code>sstream</code> header for libstdc++, I only see a copy being made and returned. How is the lifetime restricted?</li>
  <li>Why this is the desired behavior, especially since it is such a common gotcha. If a copy is being made anyway, why can't I take ownership of it?</li>
  </ol>
  
  <p>Note that this is not a duplicate of <a href="https://stackoverflow.com/questions/1374468/c-stringstream-string-and-char-conversion-confusion">stringstream, string, and char* conversion confusion</a>. That goes over explaining the behavior and workarounds; I'm looking for mechanics and rationale.</p>