title: Is destructor called when removing element from STL container?
body: <p>Say I have two containers storing pointers to the same objects:</p>
  
  <pre><code>std::list&lt;Foo*&gt; fooList;
  std::vector&lt;Foo*&gt; fooVec;
  </code></pre>
  
  <p>Let's say I remove an object from one of these containers via one if its methods:</p>
  
  <pre><code>std::vector&lt;Foo*&gt;::iterator itr = 
    std::find( fooVec.begin(), fooVec.end(), pToObj );
  fooVec.erase( itr );
  </code></pre>
  
  <p>CppReference says that this calls the object's destructor. Does this mean that the pointer to the object in <code>fooList</code> is a dangling pointer?</p>
  
  <p>I'd prefer not to use reference counted pointers. How can this problem be handled?</p>