|
Boost Users : |
Subject: Re: [Boost-users] Boost:Bind//Boost:Function -- Need some help with a constructor trying to bind to a function
From: Alan M. Carroll (amc_at_[hidden])
Date: 2008-11-02 21:45:57
I would think the value in the constructor should be bind(&Alpha::MethodsInHere::doesSomething, mih, _1)
When you bind a non-static method, the first argument must be something with which you can call the method. That would not be eh. Of course, you have will have lifetime or copy issues with mih, but I presume you have arrangements for that and we're just seeing some simplified code.
At 02:48 PM 11/2/2008, you wrote:
>4. Finally, we have an initialization class. This class wants to instantiate the EventHandler object, and to do so needs to bind the method in #2 to pass in as an argument.
>
>POD::POD* instance = new POD::POD();
>Alpha::MethodsInHere mih;
>EventHandler eh(boost::bind(&Alpha::MethodsInHere::doesSomething, ????, _1))
>
>--------
>
>My question is basically if this is possible. I was having a ton of trouble getting this to work, and after digging through some docs it seems like the '?????' in line of code in #4 needs to be a reference to eh . . . which isn't constructed yet.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net