Erasing single element in std::forward_list -- prev_it=it or ++prev_it?
<p>Let's suppose I have a singly-linked list alike <code>std::forward_list</code>. I would like to find a <em>single</em> list element matching the predicate, perform a few operations on it and optionally remove it based on another predicate.</p>

<p>So far, I've assembled the following:</p>

<pre><code>for (T::iterator it = l.begin(), prev_it = l.before_begin();
        it != l.end();)
{
    if (predicate)
    {
        // ...

        if (another_predicate)
        {
            l.erase_after(prev_it);
            break;
        }
    }

    prev_it = it;
    ++it;
}
</code></pre>

<p>However, I'm especially wondering if it's the most optimal way of performing the increment part. Alternatively, I have been considering:</p>

<pre><code>    ++prev_it;
    ++it;
</code></pre>

<p>While in plain C the former would be obviously better, in C++ that seems not that clear anymore. I believe that with simpler iterators, the former should be simpler; however, if copying the iterator may involve memory allocation (e.g. when using PImpl), the latter may actually be better.</p>

<p>Which method do you consider superior and why? Please note that I'd like to avoid limiting this strictly to a common <code>std::forward_list</code> design and consider a solution which would work with more complex types.</p>
