title: Copy a list and an associated iterator
body: <p>Suppose I have a list that I iterate over.  When I find something interesting I want to take a copy and do something at that point:</p>
  
  <pre><code>std::list&lt;int&gt; a;
  for(auto i = a.begin(); i != a.end(); ++i)
  {
     if(is_interesting(*i))
     {
        std::list&lt;int&gt; b = a;  // take a copy
        do_something(b, i);  // :(
     }
  }
  </code></pre>
  
  <p>Of course this is not going to work because the iterator <code>i</code> refers to <code>a</code> and not <code>b</code>.  How do I get an iterator <code>j</code> that refers to the same position in <code>b</code> that <code>i</code> refers to in <code>a</code>?</p>