Quick Q: Does [=] capture all variables in scope? -- StackOverflow
Quick A: No.
A simple but important question:
C++11 lambda capture semantics
When I use
[=]to indicate that I would like all local variables to be captured by value in a lambda, will that result in all local variables in the function being copied, or just all local variables that are used by the lambda?So, for example, if I have:
vector<int> my_huge_vector(100000); int my_measly_int; some_function([=](int i){ return my_measly_int + i; });Will
my_huge_vectorbe copied, even though I don't use it in the lambda?

If you're familiar with functional language styles and you want an advanced look at how your favorite functional styles are supported in modern C++, with a dash of Haskell, check out these three videos by Bartosz Milewski: