Lambdas are compiler friendly. They reliably inline unlike standalone functions. It's not laziness, it's an optimization.
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.
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.
#include <cstdio>
int main() {
auto square = [](double x) -> double { return x*x; };
printf("%f\n", square(10));
return 0;
}
since 2011