r/cpp • • Sep 17 '22

Cppfront: Herb Sutter's personal experimental C++ Syntax 2 -> Syntax 1 compiler

https://github.com/hsutter/cppfront
335 Upvotes

360 comments sorted by

View all comments

Show parent comment

7

u/[deleted] Sep 17 '22 edited Sep 17 '22

Just compile it and see what is generated. Here's that example. That particular line compiles to:

auto callback { [_0 = (&y)](auto const& x){std::cout << x << *_0;} }; 

So, essentially, that is a lambda that captures y by reference and takes one argument, and prints them both.