Boost logo

Boost Users :

Subject: Re: [Boost-users] Using a shared_ptr in a boost::function definition?
From: Ashley McConnell (ashley_at_[hidden])
Date: 2009-05-04 10:17:44


Igor R wrote:
>
>> void setCompleteFunction(boost::function< void (int errorCode, const
>> string
>> &data, HeaderMapPtr headers) > f);
>>
>> I try to bind to it: -
>>
>> wc->setCompleteFunction(boost::bind(&NetworkEventHandler::receiveSkinDownloadResult,
>> this, _1, _2, _3, wc,myFile, filename.str(), carId, crc,
>> networkPlayerId));
>
> The boost::function you have to pass as a parameter gets 3 parameters.
> If you want to "delay" passing all the 3 params, you create the
> following binder:
> bind(&NetworkEventHandler::receiveSkinDownloadResult, this, _1, _2, _3);
> If you want to bind some of params, you can do it like this:
> bind(&NetworkEventHandler::receiveSkinDownloadResult, this,
> knownErrorCore, _1, _2);
>
>

Hi Igor,

You can supply more parameters than the defined function as long as you
explicitly set the rest of the parameters (so when the function with 3
parameters is called it'll supply the other parameters too to the
"receiving" function).

I think Peter has the answer with his reply, I am using too many parameters
(there is a limit it seems). I'll try to bunch them together in a structure
perhaps.

Thanks for your help
All the best,
Ash

-- 
View this message in context: http://www.nabble.com/Using-a-shared_ptr-in-a-boost%3A%3Afunction-definition--tp23360396p23368889.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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