Skip to content

Instantly share code, notes, and snippets.

@fortheday
Created July 23, 2018 03:25
Show Gist options
  • Save fortheday/10afff5b5c8c22abace7861c627991a3 to your computer and use it in GitHub Desktop.
Save fortheday/10afff5b5c8c22abace7861c627991a3 to your computer and use it in GitHub Desktop.
void TestLambda()
{
int i = 0;
double d = 0.0;
auto f0 = []() { puts("aa"); }; // sizeof(empty struct) == 1
auto f1 = [myI = i]() { }; // sizeof(struct { int }) == 4
auto f2 = [myD = d]() { }; // sizeof(struct { double }) == 8
printf("sizeof f0[%zu] f1[%zu] f2[%zu]", sizeof(f0), sizeof(f1), sizeof(f2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment