title: Pointers to elements of std::vector and std::list
body: <p>I'm having a <code>std::vector</code> with elements of some class <code>ClassA</code>. Additionally I want to create an index using a <code>std::map&lt;key,ClassA*&gt;</code> which maps some key value to pointers to elements contained in the vector.</p>
  
  <p>Is there any guarantee that these pointers remain valid (and point to the same object) when elements are <em>added</em> at the end of the vector (not <em>inserted</em>). I.e, would the following code be correct:</p>
  
  <pre><code>std::vector&lt;ClassA&gt; storage;
  std::map&lt;int, ClassA*&gt; map;
  
  for (int i=0; i&lt;10000; ++i) {
    storage.push_back(ClassA());
    map.insert(std::make_pair(storage.back().getKey(), &amp;(storage.back()));
  }
  // map contains only valid pointers to the 'correct' elements of storage
  </code></pre>
  
  <p>How is the situation, if I use <code>std::list</code> instead of <code>std::vector</code>?</p>