C++11 lambda capture by value captures at declaration point

Lambda functions are invoked by actually passing captured parameters to the function.

value is equal to 0 at the point where the lambda is defined (and value is captured). Since you are capturing by value, it doesn’t matter what you do to value after the capture.

If you had captured value by reference, then you would see a 1 printed because even though the point of capture is still the same (the lambda definition) you would be printing the current value of the captured object and not a copy of it created when it was captured.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)