
AMDG Kurt Kohler wrote:
I have some code that uses pointers to member functions (not boost.function). It compiles and works fine. But when I tried to convert the code to use boost.function, I got a mess of errors. I know I'm doing something wrong, but I have no idea what it is. A clue would be greatly appreciated.
When you use Boost.Function with member functions, you need to pass "this" as the first argument. #include <boost/function.hpp> struct X { double f(double x) { return x; } double g(double x) { return -x; } typedef boost::function<double(X*, double)> ftype; double call(ftype func, double x) { return func(this, x); } }; int main(int argc, char *argv[]) { X x; x.call(&X::f, 1.0); x.call(&X::g, 2.0); } In Christ, Steven Watanabe