Quick A: They generate a templated operator()
, and that means you can call the same closure object with all sorts of different parameters and it just stamps out the function for each set of parameter types.
A "new classic" question on SO, classic because it was posted a year ago, but newly relevant because now the mainstream compilers are implementing the feature:
How does generic lambda work in C++14?
How does generic lambda work (
auto
keyword as argument type)?Is it similar to templates where for each different argument type compiler generates functions with the same body but changed types or is it more similar to Java's generics?
Code example:
auto glambda = [](auto a) { return a; };
Add a Comment
Comments are closed.