Created
February 19, 2018 16:36
-
-
Save mikeash/f63f610d5421a33e1856a136fc75124a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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