Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost::bind with boost::function
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-11-23 22:48:32


On Mon, Nov 23, 2009 at 5:12 PM, <maruthilakshman-boost_at_[hidden]> wrote:
> I'm using Boost ver 1.39.0
>
> I have a module to which other modules can register callbacks. This module
> will call those callbacks with a couple of arguments - as an example
>
> registerCallBack(void (*callbackFunc)(int));
>
> At the time of callback it will call: (*callbackFunc)(3);
>
> To allow for any function to be registered (each module's callback may have
> a different signature etc, but everyone can allow for this one last arg), I
> declared it to take a
> boost::function<void (int)>
>
> I was hoping that if I have a twoarg_callback(int, int) function, I can
> register it with the module by using boost::bind to bind the first argument,
> but that is not possible. I am unable to assign the return value of
> boost::bind to a boost::function<void (int)> object by binding one argument.
> However, assigning the return value of boost::bind where all the arguments
> of a function are bound (so the resulting object is a void() function) seems
> to work.
>
> I'm trying to decipher the errors, but would appreciate any help I can get.
> I get errors both on VisualStudio 2008, as well as g++ 4.1.2, so I'm
> guessing it's not some compiler problem rather it's my usage. Attached a
> sample source file. I commented out the 4 lines that were giving me errors.

And please please please do not put your emails as black text on a
transparent background. Those of us with black backgrounds see
*nothing*. If you specify a text color, then *make*certain* to
specify a background color too, but better still, send your emails as
plain text.


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