Skip to content

Instantly share code, notes, and snippets.

@cqfd
Last active August 8, 2018 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cqfd/5b43c4585145eb5058aa8361d7cdd620 to your computer and use it in GitHub Desktop.
Save cqfd/5b43c4585145eb5058aa8361d7cdd620 to your computer and use it in GitHub Desktop.
Fun C++ lambda example
#include <iostream>
int g = 0;
auto f = [g=g](auto x) mutable {
static auto count = 0;
std::cout << "count: " << ++count << std::endl;
std::cout << "g: " << ++g << std::endl;
};
int main() {
f(1);
f(2);
f(3.0f);
f(4.0f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment