#include <iostream> #include <unordered_map>
#include <boost/bind.hpp>
using namespace std;
struct A { void print(int x) { cout << x << endl; } void print2(int x) { cout << "2 " << x << endl; } }; struct B { void print(long long x) { cout << x << endl; } }; struct C { void print(int x) { cout << x << endl; } int sth; };
int main() { unordered_map<int, decltype(boost::bind(&A::print, A(), int()))> ma;
A a; int x = 2333; auto f = boost::bind(&A::print, a, x); ma.insert(make_pair(2, f)); x = 0; auto it = ma.find(2); if (it != ma.end()) { it->second(); } else { cout << "not found\n"; }
long long llx = 23333; B b; auto g = boost::bind(&B::print, b, llx); llx = 0;
x = 2333; C c; auto h = boost::bind(&C::print, c, x); x = 0;
x = 23332; auto f2 = boost::bind(&A::print2, a, x); ma.insert(make_pair(5, f2)); ma.find(5)->second();
return 0; }
|