See i am not against for_each, but you may not realize, since you seem so used to it, (honestly i am very impressed by your C++ knowledge), but although, for_each seems so easy, but to run it you need to know a dozens of background details, which you will forget almost after you have used it, it happens to me :(Quote:
Of course they are not always possible, or at least not possible while remaining efficient. I cited the case of std::sort versus std::list::sort as an example. As such, so what if they are not always possible within the given constraints?
The more understandable would be this, and not your silly for_each:Quote:
for_each is not part of the C++ core language but it is part of the C++ standard library. The only benefit of for_each is in abstracting away the loop - if feasible the more appropriate generic algorithms should be used to better describe what is happening.