Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created February 19, 2018 16:36
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 mikeash/f63f610d5421a33e1856a136fc75124a to your computer and use it in GitHub Desktop.
Save mikeash/f63f610d5421a33e1856a136fc75124a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <functional>
using namespace std;
void f(std::function<void(int)> call) {
call(1);
call(2);
call(3);
}
int main()
{
int x = 42;
f([&](int param) {
x += param;
cout << "param is " << param << ", x is " << x << endl;
});
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment