can unary predicate for remove_if have sideeffects?
c++, stl
Solution
The standard does indeed guarantee that, so you are fine. I would still consider it bad style except for debugging, though.
Problem
If those arent modifying the container? For example I want to output all the ints I'm removing from a vector(and I dont want to use multiple passes: eg: partition + output + erase). Design horribadness aside is this 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 a predicate on each element so I am fine, since I dont care about the order...