title: Shouldn't istream::peek() always return what you just putback()?
body: <p>Intuitively, judging from the C++ spec, it looks to me as if <code>istream::putback( c )</code> should always arrange the input buffer such that the next call to <code>istream::peek()</code> should read the character <code>c</code>. Is this not correct? I ask because the latest version of libc++ shipping with Xcode 4.6 seems not to enforce this behavior in all cases—particularly when the last character is at the EOF. The same is true if you use <code>unget()</code> instead of <code>putback( c )</code>. </p>
  
  <p>Is libc++'s behavior correct, or is my intuition of how <code>putback()/unget()</code> should work correct?</p>
  
  <p>Consider this example code, which works with libstdc++ but not with libc++ (the assertion fails).</p>
  
  <pre><code>#include &lt;sstream&gt;
  #include &lt;cassert&gt;
  
  int main(int argc, const char * argv[])
  {
      std::istringstream in( "[Test]" );
  
      while( in )
      {
          int c = in.get();
          if( c == ']' )
          {
              in.putback( c );
              assert( in.peek() == c );   // Fails with libc++. Succeeds with libstdc++.
              break;
          }
      }
  
      return 0;
  }
  </code></pre>