Skip to content

Instantly share code, notes, and snippets.

@apathyboy
Created June 21, 2010 21:49
Show Gist options
  • Save apathyboy/447558 to your computer and use it in GitHub Desktop.
Save apathyboy/447558 to your computer and use it in GitHub Desktop.
#include <functional>
#include <iostream>
void f(int a, int b);
void g(int a, int b, float c, float d);
typedef std::function<void (int, int)> TestCallback;
int main() {
TestCallback callback1 = std::bind(&f, std::placeholders::_1, std::placeholders::_2);
callback1(1, 2);
TestCallback callback2 = std::bind(&g, std::placeholders::_1, std::placeholders::_2, 12.2f, 12.5f);
callback2(1, 2);
return 0;
}
void f(int a, int b) {
std::cout << a << " " << b << std::endl;
}
void g(int a, int b, float c, float d) {
std::cout << a << " " << b << " " << c << " " << d << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment