I don't have Boost installed, so I solved the problem like this:
template<typename pType,typename retType>class FunctorBase{public: virtual retType call(pType)=0;};template<class OType,typename pType,typename retType>class Functor : public FunctorBase<pType,retType>{public: Functor(OType* objInst,retType (OType::*objFunc)(pType param)) :objInst(objInst),objFunc(objFunc) {} retType call(pType param){ return (*objInst.*objFunc)(param); }private: OType* objInst; retType (OType::*objFunc)(pType);};
It's probably not the best solution, but it works.
Say you have a PopupMenu class, which you want to notify a ButtonEventHandler every time a button is clicked. The PopupMenu doesn't need to know which object it will be notifying, or the type of that object.
PopupMenu has a FunctorBase<pType,retType> member, where pType is the type of the parameter in the function call, and retType is the type the function returns.
Somewhere in your program (probably in the EventHandler), you store a Functor<OType,pType,retType> object. Since the EventHandler object is being called, OType = EventHandler.
The functor in EventHandler is constructed like this:
popupMenuFn(this,&EventHandler::PopupMenuButtonClicked), where the object instance is just the this pointer, and the name of the method being called is PopupMenuButtonClicked
The PopupMenu object receives a pointer to this functor in it's constructor, and when it wants to make a function call, it just calls functorPointer->call(parameter);