title: std::list erase incompatible iterator
body: <p>I have list with objects. I get some items from that list and do something with items. If work is done without errors i wish to delete these items from list. After that, on erase I get exception of incompatible iterator. I understand that tmp is different list. But how to solve this problem?</p>
  
  <pre><code>#include &lt;list&gt;
  
  class A
  {
  public:
      A(int i):i_(i){}
  private:
      int i_;
  };
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      std::list&lt;A&gt; list;
      A a(1), b(2), c(3);
      list.push_back(a);
      list.push_back(b);
      list.push_back(c);
  
      std::list&lt;A&gt; tmp;
      tmp.insert(tmp.end(), list.begin(), list.end());
      // do something with tmp
      // if all is ok, then erase what is done
      list.erase(tmp.begin(), tmp.end());
  
      return 0;
  }
  </code></pre>
  
  <p><code>tmp.Insert</code> not always get full <code>list</code>. It can copy part of <code>list</code>, so i don't want clear whole <code>list</code>.</p>