title: Is remove_if predicate guaranteed to be called only once per iterator?
body: <p>I've been reading the latest C++ spec, and I'm unable to figure out whether or not <code>remove_if</code> can be called multiple times for the same element. In particular, I'm looking at <code>std::remove_if</code> being called on <code>deque</code> iterators. So far as I can figure, there's no <em>reason</em> for it to be called multiple times if all it does is simply start from the first param and iterate along till the second.</p>
  
  <p>The code I'm working on uses manual reference counting and, as such, in case the <code>remove_if</code> predicate will return true, it'll decrement and delete the underlying object reference. The obvious catch being that this will only work if the <code>remove_if</code> predicate is only called once for each element, otherwise subsequent calls will be accessing a deleted object. Something tells me this isn't guaranteed to be OK and there will come a point where the same element will be passed to the <code>remove_if</code> predicate twice for a single <code>remove_if</code> call.</p>
  
  <p>If you had some kind of crazy datastructure that implemented iterators and say, randomly selected an entry for each iterator increment until it (randomly) came upon the end iterator, I could see how this would fail. But for straight-forward, standardized structures like <code>deque</code>, <code>vector</code>, and <code>list</code>, can a single element be passed multiple times to the predicate?</p>