Skip to content

Instantly share code, notes, and snippets.

@Garciat
Last active August 29, 2015 14:06
Show Gist options
  • Save Garciat/6a0b2383315c0c3cce5f to your computer and use it in GitHub Desktop.
Save Garciat/6a0b2383315c0c3cce5f to your computer and use it in GitHub Desktop.
// lambda syntax; construction & call
int x = 0;
int y = 10;
[x, &y] (int z) { return x + (++y) + (++z); } (5);
// desugared
struct __lambda1 {
int x;
int &y;
constexpr __lambda1(int _x, int &_y) : x(_x), y(_y) { }
decltype(auto) operator() (int z) const {
return x + (++y) + (++z);
}
};
// construction & call
int x = 0;
int y = 10;
__lambda1(x, y)(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment