Using boost::bind with boost::function

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

maruthilakshman-boost@yahoo.com wrote: ...
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
object by binding one argument.
Use boost::bind( twoarg_callback, 3, _1 ). The 'int' in function

On Mon, Nov 23, 2009 at 5:12 PM,
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
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
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.

AMDG OvermindDL1 wrote:
On Mon, Nov 23, 2009 at 5:12 PM,
wrote: <snip>
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.
FWIW, that message was sent in *both* plain text and html. In Christ, Steven Watanabe

On Mon, Nov 23, 2009 at 9:44 PM, Steven Watanabe
AMDG
OvermindDL1 wrote:
On Mon, Nov 23, 2009 at 5:12 PM,
wrote: <snip>
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.
FWIW, that message was sent in *both* plain text and html.
And my client is capable of rendering HTML, but your HTML message specified a foreground color, but no background color, thus it defaulted to transparent, meaning that my window background color of black shows through, so your black text was on a transparent background, that was actually black. If you are going to specify a foreground color in your HTML, it is best to always specify a background color too, including on webpages as there is no actual 'default' setting for such things even in a web-browser. :)

Thanks a lot for pointing out my mistake.
About the color, I did not specify any background or foreground color. It was Yahoo! mail's default. Am trying to send this message in plain text. Will try to keep this in mind for the messages in future.
Thanks once again,
Lakshman.
________________________________
From: OvermindDL1
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
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
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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/

On Mon, Nov 23, 2009 at 10:03 PM,
Thanks a lot for pointing out my mistake.
About the color, I did not specify any background or foreground color. It was Yahoo! mail's default. Am trying to send this message in plain text. Will try to keep this in mind for the messages in future.
Yeah, Yahoo sucks, so thanks for the effort from all of us that use dark color schemes due to sensitive eyes. :)
participants (4)
-
maruthilakshman-boost@yahoo.com
-
OvermindDL1
-
Peter Dimov
-
Steven Watanabe