title: Does resizing an STL vector erase/invalidate its previous contents?
body: <p>It doesn't appear to (sample program), but can I be sure?</p>
  
  <pre><code>// does resizing an STL vector erase/invalidate it's previous contents?
  #include &lt;stdio.h&gt;
  #include &lt;vector&gt;
  using namespace std ;
  
  void print( vector&lt;int&gt;&amp; t )
  {
    for( int i = 0 ; i &lt; t.size() ; i++ )
      printf( "%d ", t[i] ) ;
    puts("");
  }
  
  int main()
  {
    vector&lt;int&gt; t ;
    t.resize( 12,9999 ) ;
    print(t) ;
  
    t.resize( 15, 10000 ) ;
    print(t) ;
  }
  </code></pre>