3 ms·
> common mistake in C++ Not really. You have to explicitly specify you want capture-by-reference with C++ lambdas. The code would also look very out-of-place
by kbwt 10y ago
> common mistake in C++
Not really. You have to explicitly specify you want capture-by-reference with C++ lambdas.
The code would also look very out-of-place to a C++ programmer, because you would never capture a loop counter by reference if you intend to use the lambda outside of the loop. Lifetimes don't just get magically extended into completely unrelated scopes.