Hacker News new | comments | show | ask | jobs | submit login

Can you always replace lambdas with iterators? For example, to visit a graph you could implement it using function that takes two arguments; the graph to visit and a lambda holding the function (functor) to apply to each node.

It is fairly easy to implement and the compiler will inline the functor so there is no performance penalty. Any solution based on iterators that I can think of would be much more complicated and would probably not lead to as efficient code.

I'll admit that the "user interface" for iterators are much nicer than using functors. The former meshes well with c++:s for loop syntax while the syntax for lambda constructs is bad.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact