title: How to get the end of a C++ string stream?
body: <p>I'm adding functions to my (simple) <a href="http://code.google.com/p/game-core/source/browse/trunk/GCore/GC_Log.h" rel="nofollow noreferrer">log class</a> to make it usable like a stream.
  Currently, after some modifications, I got this (in my cpp):</p>
  
  <pre><code>// blah blah blah...
  // note: here String is a defined as: typedef std::string String;
  
  void Log::logMessage( const String&amp; message )
      {
          logText(); // to be sure we flush the current text if any (when "composing" a message)
          addText( message ); 
          logText(); // really log the message and make the current text empty
      }
  
  // blah blah blah...
  
      Log&amp; operator&lt;&lt;( Log&amp; log, const std::stringstream&amp; message )
      {
          log.logMessage( message.str() );
          return log;
      }
  
      Log&amp; operator&lt;&lt;( Log&amp; log, const String&amp; message )
      {
          log.addText( message );
          return log;
      }
  </code></pre>
  
  <p>Now in my "client" app I'm using this code to check the result (m_log is a valid pointer as you have already guessed):</p>
  
  <pre><code>gcore::Log&amp; log = *m_log;
  log &lt;&lt; getName() &lt;&lt; " : application created.";
  log &lt;&lt; "This is a test for " &lt;&lt; getName();
  </code></pre>
  
  <p>Now the problem I got is that logText() (and logMessage) is never called because this test code will only call the &lt;&lt; operator with String.
  What I need is a way to call logText() when the given steam of string is finished :</p>
  
  <pre><code>log &lt;&lt; getName() &lt;&lt; " : application created."; 
  </code></pre>
  
  <p>would be equivalent to</p>
  
  <pre><code>log.addText( getName() );
  log.addText( " : application create." );
  log.logText();
  </code></pre>
  
  <p>I'm not sure how to do this or even if it's possible. My first guess is that it would be possible to use std::endl at the end of the stream like this : </p>
  
  <pre><code>log &lt;&lt; getName() &lt;&lt; " : application created." &lt;&lt; std::endl; 
  </code></pre>
  
  <p>Or something equivalent, but if it's possible to do it without adding objects to the stream, that would be nice.</p>
  
  <p>Any idea?</p>