Boost logo

Boost Users :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-09-30 15:47:04


On Tuesday 30 September 2003 04:12 pm, Victor A. Wagner, Jr. wrote:
> I've been over the documentation several times and I keep getting the
> feeling that I'm just missing something.
> I'd like to have some member functions (methods) as slots for some signals
> (a la QT). I suspect that there is some form of bind that I could use, but
> it's certainly not obvious to me.

Yep, bind can do it:

struct X {
  int foo(float, char);
};

signal<int (X*, float, char)> sig;
sig.connect(bind(&X::foo, _1, _2, _3));
// or
sig.connect(mem_fn(&X::foo));

The _1 is the implicit object parameter ("this") that the member function
pointer is invoked with.

        Doug


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