|
Boost Users : |
From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2008-02-22 05:19:18
Daniel Lidström wrote:
> Hello!
>
> I'm trying to use boost::bind and boost::function to perform a
> callback mechanism.
> However, the VC2005 compiler crashes for some reason. Let me show the
> code right away:
>
[snip]
> struct Fl_Widget;
>
> typedef boost::function<void (Fl_Widget&, const boost::any&)>
> CBF_Callback;
>
> struct Fl_Widget
> {
> CBF_Callback cbf_callback_;
> boost::any user_data_;
>
[snip]
>
> struct RailCaterpillarControllerGUI
> {
> Fl_Widget widget;
>
> RailCaterpillarControllerGUI()
> {
> // cbToggleDeadZone should be called by widget's callback
> CBF_Callback
> callback(boost::bind(&RailCaterpillarControllerGUI::cbToggleDeadZone,
> this));
> widget.cbf_callback(callback);
> }
>
[snip]
>
> The compiler seems to crash when trying to compile the
> RailCaterpillarControllerGUI constructor.
> Any ideas why?
> I'm using 8.0.50727.867 (vsvista.050727-8600), boost-1.34.1
Try adding the argument placeholders to your bind call:
// cbToggleDeadZone should be called by widget's callback
CBF_Callback callback(
boost::bind(
&RailCaterpillarControllerGUI::cbToggleDeadZone,
this,
_1,
_2
));
HTH / Johan
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