3 ms·
> They reliably inline unlike standalone functions. No. They don't. Non-constexpr ones can't. And lambdas with captures that outlive their creators are notorio
by notacoward 6y ago
> They reliably inline unlike standalone functions.
No. They don't. Non-constexpr ones can't. And lambdas with captures that outlive their creators are notoriously painful for compilers and libraries to support.
- ncmncm 6y agoYet, they do. Lambdas with captures are explicitly modeled as a struct holding the captured values, and a member function that takes its implicit "this". That function, with its implementation fully exposed, is as easily inlined as any other. The struct is moved or copied as needed to keep it live after the originating context evaporates.
- notacoward 6y agoI stand corrected. OTOH, "functionally equivalent but makes debugging or verification harder" isn't actually a strong argument in favor of lambdas.
- ncmncm 6y agoFortunately they don't need a strong argument. Convenience and minimized boilerplate suffices.