Quick Q: What type do lambdas get compiled into? -- StackOverflow
Quick A: A compiler-generated type that stores the captured variables in its data members, and exposes the function signature and body as its operator()
.
Recently on SO:
What type do lambdas get compiled into?
As I know all data types must be known at compile time, and lambda is not a type. Does lambda got translated into anonymous struct with operator() or std::function wrapped?
For example,
std::for_each(v.begin(), v.end(), [](int n&){n++;});