Skip to content

Instantly share code, notes, and snippets.

@ElemarJR
Created December 1, 2012 19:45
Show Gist options
  • Select an option

  • Save ElemarJR/4184473 to your computer and use it in GitHub Desktop.

Select an option

Save ElemarJR/4184473 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <functional>
using namespace std;
int main() {
function<int(int, int)> add =
[] (int a, int b) { return a + b; };
function<int(void)> magic =
[] { return 42; };
function <void(char *)> print =
[] (char* msg) { cout << msg << endl; };
print("hello world!");
cout
<< "add(2, 2) = " << add(2, 2) << endl
<< "magic() = " << magic() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment