O_o, wut? Lambda is a closure object - saying that it can only be defined / used inside functions makes as much sense than saying one can use/define the value 7 ONLY inside functions. Do not get confused that the lambda object is called "closure object" - that too is still just an object. In short, there is no such limitation.Lambdas can only be defined and used inside functions:
Perhaps you meant that defining a capturing Lambda outside functions is conceptually kinda totally bonkers -> capture list requires function scope.
Good catch! I mispoke. I meant that regular functions can only be used outside functions, but Lambdas can also be used inside functions. I think I meant to type "also" but typed "only" instead.
My favorite lambda feature is actually just using them directly as function arguments - which I completely neglected to mention.
Lambda object defines a few operators. One that seemed to cause a bit unfortunate/confusing wordings here is: type conversion operator to the underlying function type (only defined if the lambda does not capture anything - as otherwise the operator would not make any sense). IE. Lambda object is NOT just a function, however it might be possible to get a function pointer out of one via implicit/explicit conversion:
I didn't realize non-capturing lambdas didn't just compile into regular functions. Thanks for that!