
jbd
Hello,
Peter Dimov wrote: It isn't clear why do you need to bind bar2 at all, instead of just using boost::function < void (int) > f3( &bar2 ) ;
To make a long story short, i'd like people always use the same mecanism (syntax), not a boost::bind here and nothing there.
Maybe I tried to simplify my problem too much. The small code i'm "working" on is at the end of this message. I will try to say what i really want to do with words.
The idea :
class FunctionInterface : -> a pure virtual classe with an public void execute(const std::string&) = 0 member
class GeneralFunctor : -> a class with a boost::shared_ptr<FunctionInterface> function_ member which is called via the operator()(const std::string) const ; The constructor take a pointer to a FunctionInterface.
template < typename Func > class Functor : public FunctionInterface -> keeps a boost::function<Func> as a member and implement the execute function
template < typename FuncType > GeneralFunctor MakeFunctor(FuncType func) -> This is my helper function to build a GeneralFunctor from any boost::function
At first glance this looks like a very complicated and expensive way of adding an OO layer over boost::function, which is *already* providing all the dynamic polymorphism you need. I could be missing something, but maybe you just need to get comfortable with using boost::function and operator() instead of GeneralFunctor and execute()? FWIW, there's a reason we do this stuff with operator(): it improves interoperability (e.g. with STL). HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com