|
Boost Users : |
From: BRIDGES Dick (Dick.Bridges_at_[hidden])
Date: 2005-10-05 13:08:36
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Peter Dimov
> Sent: Wednesday, October 05, 2005 10:41 AM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] [bind] Member fn has defeated me
>
>
> BRIDGES Dick wrote:
>
> >> BRIDGES Dick wrote:
> >>
> >>> class Bar {
> >>> typedef void (*pf)(bool);
> >>
> >> If you make this
> >>
> >> typedef boost::function<void(bool)> pf;
> >>
> > [snip]
> >>
> >> then
> >>
> >> Bar bar_( boost::bind(&X::f, &x) );
> >>
> >> should work. But you can't get an oridnary function pointer from
> >> boost::bind; a function pointer doesn't have enough state to
> >> represent &X::f + &x.
> >
> > <error_message>
>
> [...]
>
> I omitted too much of the context, sorry ;-) For
>
> struct X
>
> {
> void f(bool b) {}
> }
>
>
> the correct thing would be to use boost::bind(&X::f, &x, _1)
> so that the
> bool argument from pf (the first input argument is _1 in bind
> notation) can
> be passed to X::f.
Works fine now. I don't know why I find boost::bind so mysterious,
but I *WILL* learn!
Thank you for both the answers and your patience.
Regards,
Dick
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