3 ms·
>The capture syntax especially is a minefield. Functors are no easier to use. Either you initialize captured values through a constructor or by manually settin
by fluoridation 3y ago
>The capture syntax especially is a minefield.
Functors are no easier to use. Either you initialize captured values through a constructor or by manually setting each member. In both cases you have to name the same values several times and ensure that you're doing it correctly. With lambdas, if capture by value or by reference is enough for everything you need, the code is much more succinct and readable. It seriously reduces useless, error-prone boilerplate.
>And are the runtime guarantees exactly the same as that of a local class instance?
Yes.
>The question is - what does this extra complexity buy us? Is it worth it?
It buys us more readable and straightforward code. Yeah, I'd say it's worth it. I haven't written a functor in years.