Boost logo

Boost Users :

Subject: Re: [Boost-users] [function / bind] How to register callbacks using boost::function/bind?
From: Olivier Tournaire (olitour_at_[hidden])
Date: 2013-02-04 08:14:47


Great answer and explanations. Works like a charm :)

2013/2/4 Steve Lorimer <steve.lorimer_at_[hidden]>

> The problem is here:
>
>
>
> converter->register_error_callback( boost::bind(&another_class::log_error, converter, _1) );
>
>
> The second parameter to bind should be an instance of the class whose member function you're trying to bind to:
>
>
> It should rather be
>
>
> converter->register_error_callback( boost::bind(&another_class::log_error, *another_class_instance*, _1) );
>
>
> Under the hood, what will be happening is boost::function will call *another_class_instance->log_error(...)*
>
> *
> *
>
> If you think about it, you can't call converter->log_error, since coordinates_converter::log_error doesn't exist.
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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