title: Why does removing the _first_ element of a list invalidate `.rend()`?
body: <p>Tested on Mac OS X using XCode 4.6.</p>
  
  <p>This example code shows removing the last element of an <code>std::list</code> works as I expected:  an iterator reference to <code>list::end()</code> is still "1 past the end" and is still valid, <strong><em>even through removal of the last element</em></strong>.</p>
  
  <p>But the second example counters my intuition.  Removing the <em>first</em> element of the list <strong>changes <code>list::rend()</code></strong>, which I thought was "1 past the beginning".</p>
  
  <p>Was my expectation wrong?  Why was it wrong?  Why does your reference to "1 past the end" through deletion of the last element remain valid (should it not?), but a reference to "1 in front of the beginning (<code>.rend()</code>) becomes invalid after removal of the front element?</p>
  
  <pre><code>void printList( list&lt;int&gt;&amp; os )
  {
    for( int&amp; i : os )
      printf( "%d ", i ) ;
    puts("");
  }
  
  void testList()
  {
    list&lt; int &gt; os ;
    os.push_back( 1 ) ;
    os.push_back( 2 ) ;
    os.push_back( 3 ) ;
    os.push_back( 4 ) ;
    os.push_back( 5 ) ;  
  
    // Forward iterators:  reference to .end() not invalidated when remove last elt.
    list&lt;int&gt;::iterator fwdEnd = os.end() ;
    printList( os ) ;
    os.erase( --os.end() ) ; // remove the 5 (last elt)
    printList( os ) ;
    if( fwdEnd == os.end() )  puts( "YES, fwdEnd==os.end() still, iterators not invalidated" ) ;  // I get __this__ result
    else puts( "NO: fwdEnd INVALIDATED" ) ;
  
  
  
    list&lt;int&gt;::reverse_iterator revEnd = os.rend() ;
    // remove the front element
    printList( os ) ;
    os.erase( os.begin() ) ; // removes the 1
    printList( os ) ;
    if( revEnd == os.rend() )  puts( "YES revEnd is still valid" ) ;
    else  puts( "NO: revEnd NOT valid" ) ; // I get __this__ result
  }
  </code></pre>