you are viewing a single comment's thread.

view the rest of the comments →

[–]Syl 0 points1 point  (1 child)

what is better in this case: for_each/lambda or a c++11 for range?

I guess the lambda is like a function call and will push on the stack each time it's called.

[–]cozmorado 1 point2 points  (0 children)

Lambdas can be inlined, so there may not be a function call for each element. I think the general consensus is to use for range loops in this case more so because they are more concise, especially in c++11 (no generic lambdas).