Boost logo

Boost Users :

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


On Wednesday 01 October 2003 12:36 am, Victor A. Wagner, Jr. wrote:
struct X {
  int foo(float, char);
  void blah() const;
};

X xt;
signal<void(X*)> sigx;
sigx.connect(bind(&X::blah, &xt));

> /// the above is more in line with what QT does with it's connect
> (i.e. binds it to an instance and method)
> /// now only if there were some nifty syntactic sugar we could come up
> with so we could:
> sigx.connect(magicsugar(&xt.blah));
> /// which would more clearly show the intent, IMO

The bind syntax easily extends to more involved examples (e.g., reordering
parameters, binding other parameters, or even nested bind expressions),
whereas other, simpler syntax does not. It's somewhat of an acquired taste,
but once you've really "got it" you'll never be able to go back.

> btw, I sent you a bug report w/ msvc++7.1 and debug assertion (heap not
> valid) when destructing a signal

I see it, and will try to duplicate the problem locally.

        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