I have a question about calling a lambda function as was described in SO Documentation.
int multiplier = 5;
auto timesFive = [multiplier](int a) { return a * multiplier; };
std::cout << timesFive(2); // Prints 10
multiplier = 15;
std::cout << timesFive(2); // Still prints 2*5 == 10
Why doesn't it print 2 * 15 = 30
?
Clearly, the value of multiplier is being modified and when the call to timesFive
is made, it should pick updated value of multiplier
.