title: Why does writing into temporary string stream object only print object addresses?
body: <p>The following snippet is simplified version of a logger that I use. It extends <code>std::ostringstream</code> and can be filled using the <code>&lt;&lt;</code>-operator. Upon destruction all content is written to <code>std::cout</code>.</p>
  
  <p>Writing (<code>&lt;&lt;</code>) directly into a temporary object, <code>Logger()</code>, I would expect it to print that input, however, it only prints the address of something on <code>std::cout</code>. When writing into a reference of a temporary object, <code>Logger().stream()</code>, works as expected.</p>
  
  <p>Why is that happening?</p>
  
  <p>Btw, this behavior only occurs in C++98-land (<a href="http://ideone.com/7RLSaf">ideone</a>), which I have to use. With C++11 (<a href="http://coliru.stacked-crooked.com/a/3c2af774bb958c44">coliru</a>) and C++14 (<a href="http://ideone.com/cPgn4k">ideone</a>) both call variants work as expected. What's different in C++11/14?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  
  class Logger : public std::ostringstream
  {
  public:
      ~Logger()
      {
          std::cout &lt;&lt; this-&gt;str() &lt;&lt; std::endl;
      }
  
      Logger&amp; stream()
      {
          return *this;
      }
  };
  
  int main( int argc, char ** argv )
  {
      // 1.
      // Prints an address, e.g. 0x106e89d5c.
      Logger() &lt;&lt; "foo";
  
      // 2.
      // Works as expected.
      Logger().stream() &lt;&lt; "foo";
  
      // What is the difference between 1. and 2.?
  
      return 0;
  }
  </code></pre>