I\'m trying to create a map of string and method in C++, but I don\'t know how to do it. I would like to do something like that (pseudocode):
map
The easiest way would be to use boost::function:
#include #include #include using namespace std; // later... map > funcs; funcs["sin"] = &Math::sinFunc;
It gets slightly more complex if you're using member functions - boost::lambda can help:
#include #include #include #include using namespace std; namespace l = boost::lambda; // later... Math *m = new Math(); map > funcs; funcs["sin"] = l::bind(&Math::sinFunc, m, l::_1);