Re: [sigc] Re: [Boost-users] Signals & Slots



On Saturday 20 November 2004 20:58, Carl Nygard wrote:

[snip]

> > 5. I can't find a mention of member method handlers. I would prefer that
> > the simple stuff that I mentioned was dealt with first.
>
> http://www.3sinc.com/opensource/boost.bind-vs-sigc2.html#slot
>
> Only given discussion, no real example code.  I'm assuming discussion in
> the example code, but I'll add a code snippet.

Carl,

There are some errors in your examples.

With the following specimen code you provide:

  class Foo {
  public:
      // ...
      int Func(float val, string str);
  };
  Foo obj;
  boost::signal<int, float, string> sig;

To connect the boost signal to a boost function object (the libsigc++ 
equivalent of a slot) the expression is not:
  sig.connect(boost::bind(&Foo::Func, obj));
but is:
  sig.connect(boost::bind(&Foo::Func, obj, _1, _2)); or
  sig.connect(boost::bind(&Foo::Func, &obj, _1, _2));
(both do the same).

And with a libsigc++ signal:
  sigc::signal<int, float, string> sig;
the expression is not:
  sig.connect(sigc::mem_fun(&Foo::Func, obj));
but is:
  sig.connect(sigc::mem_fun(obj, &Foo::Func));

This is as I had used it with boost 1.30, but I don't think this has changed 
with boost 1.32, which has just come out (boost tries to keep its API 
reasonably stable between releases).  See the examples I posted for further 
details.

Chris.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]