Quick Q: What type do lambdas get compiled into?—StackOverflow

Save to:
Instapaper Pocket Readability

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++;});

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.