Comment by Too
4 years ago
C++ lambda captures work exactly like this. You need to state which variables that should be part of the closure and whether they should be mutable and by reference or copies.
auto result_value = [var1, var2, &var3]() {
var3 = var1 + var2
return var1 * var2
}()
return result_value * 5
Does anyone know if compiler is smart enough to inline self-executing lambda as above? Or will this be less performant than plain blocks?
No comments yet
Contribute on Hacker News ↗