Should these arent modifying the container? For example, I want to deduce all those that I delete from the vector (and I do not want to use several passes: for example: section + output + erasure). Deviation of design from this is legal:
v.erase(remove_if(v.begin(), v.end(), [] (const int i) -> bool
{
if (i%2==0)
{
cout << i << endl;
return true;
}
else return false;
}, v.end());
AFAIK standard guarantees exactly one application of the predicate for each element, so I am fine, since I do not care about the order ...
source
share