As TC said in a comment, No. 1 does not require capture, since x
is known at compile time and therefore baked into lambda. It doesn't seem like the f
function is known at compile time, so it doesn't need to be captured.
I believe that if you change the signature of f
to int const &
, you are now trying to pass the address of a constant on the stack, thereby undergoing changes, and this will require capturing x
by value or reference.
source share