Firstly:
int lf = [/*captures*/]() {/*body*/};
is incorrect code, it should be
// case 1. lambda is automatic
auto lf = [/*captures*/]() {/*body*/}; // closure object
or (provided that lambda returns something compatible to int
)
// case 2. lambda is temporary
int lf = [/*captures*/]() {/*body*/} (); /* calling object created */
lambda expression is a shorthand notation for creation of object with a unique class
(very simplified, you have to look in standard or in language reference for full description):
class Closure {
/* members storing captured values or references */
public:
return-type operator( /* argument list*/ ) { /*body*/ };
}
In first case lambda would be stored in stack, in second case it is a temporary object.
So lambda with a capture list would store such object, i.e. all captured values exactly where you instructed it to store lambda object, in your case it's automatic storage (so called, "stack"). Using a capture-less lambda is no different from declaring a function and using a pointer to it, there is no storage associated with it and it can be casted to a function pointer.