title: Why do compilers now accept to call str() member on a returned std::ostream& from std::stringstream::operator<<()?
body: <p>Consider the following line:</p>
  <pre><code>std::string s = (std::stringstream() &lt;&lt; &quot;foo&quot;).str();
  </code></pre>
  <p>This should not compile because <code>std::stringstream::operator&lt;&lt;()</code> is inherited by <code>std::ostream</code> and returns a <code>std::ostream&amp;</code> which <strong>does not have</strong> an <code>str()</code> member.</p>
  <p>It seems the main compilers are now accepting this code where they didn't in the past. What standard change happened to make this compile?</p>
  <p>I made some tests with <em><a href="https://en.wikipedia.org/wiki/GNU_Compiler_Collection" rel="noreferrer">GCC</a></em>, <em><a href="https://en.wikipedia.org/wiki/Clang" rel="noreferrer">Clang</a></em> and <em><a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B" rel="noreferrer">MSVC</a></em> and I could find the version where the change happened:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Compiler</th>
  <th style="text-align: center;">Rejects until (version)</th>
  <th style="text-align: center;">Accepts from (version)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>GCC</td>
  <td style="text-align: center;">11.1</td>
  <td style="text-align: center;">11.2</td>
  </tr>
  <tr>
  <td>Clang</td>
  <td style="text-align: center;">12.0.1</td>
  <td style="text-align: center;">13.0.0</td>
  </tr>
  <tr>
  <td>MSVC</td>
  <td style="text-align: center;">v19.14</td>
  <td style="text-align: center;">v19.15</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><sup>You can <a href="https://godbolt.org/z/hn7jGo5c1" rel="noreferrer">find the test here</a></sup></p>