
on Wed Sep 26 2007, "Preston A. Elder" <prez-AT-neuromancy.net> wrote:
(repost, I accidentally posted this to boost::build list ... ugh).
I have written code to solve this problem:
I have class foo, like so:
class foo { boost::function<void (foo *)> func_ptr;
void call() { func_ptr(this); } };
I want func_ptr to be either a free-standing function (or class static), OR a class member function of a derived class, so:
void bar(foo *f) { ... }
OR:
class baz : public foo { public: baz() { func_ptr = &baz::doit; }
void doit() { } };
The obvious problem with the latter is that it needs to be downcast implicitly, and some kind of exception thrown if the wrong type is passed.
I think this is what Boost.Bind is for. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com