Boost logo

Boost Users :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-02-17 09:08:09


On Saturday 15 February 2003 09:48 am, "yjwang_bj wrote:
> Hi, all.
>
> I'm working in a project that need loosely coupling. I find
> boost::signals is perfect for that, save one exception.
>
> My question is that I want to connect arbitrary member function to
> signal. How to do it?

Use the Bind or Lambda library. An example:

class X {
public:
  void foo(int);
};

X* x;
boost::signal<void (int)> sig;

// So the signal will call x->foo(y) when sig(y) is called:
sig.connect(boost::bind(&X::foo, x, _1));
  
        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