Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-05-30 13:58:46


Darren Vincent Hart wrote:
[...]
> struct handler
> {
> char key_;
> boost::signal<bool ()> sig;
>
> handler(char key) : key_(key) { }
>
> bool operator()(char key)
> {
> cout << "handler::operator() - received a " << key << endl;
> if (!sig.empty() && key == key_)
> {
> cout << "\texecuting slot\n\t";
> sig();
> }
> cout << endl;
> return true;
> }
> };

[...]

> // THE PROBLEM IS HERE - HOW DO I BIND TO handler_a.test(char) ?
> widget_b.keypress.connect( boost::bind(&handler::operator(),
> &handler_a) );
> // END PROBLEM

I think that you want

widget_b.keypress.connect( boost::ref(handler_a) );

The reason for the error is that &handler::operator() takes two arguments
(the implicit 'this' and 'char key') but you are trying to bind it to just
one, &handler_a. The correct statement is

widget_b.keypress.connect( boost::bind(&handler::operator(), &handler_a,
_1) );


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