Boost logo

Boost Users :

From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2004-11-17 08:39:07


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of WangYun
> Sent: Tuesday, November 16, 2004 10:03 AM
> To: boost-users
> Subject: [Boost-users] Signal with return value will crash
>
> I tried the signals, the code below will crash
>
> #include <boost/signal.hpp>
> int _tmain(int argc, _TCHAR* argv[])
> {
> boost::signal<int(int)> _sig;
> _sig(10);
>
> return 0;
> }
>
> but code below works well
>
> #include <boost/signal.hpp>
> int _tmain(int argc, _TCHAR* argv[])
> {
> boost::signal<void(int)> _sig;
> _sig(10);
>
> return 0;
> }
>
> The only difference is one has return value, the other doesn't, is
this a
> bug or by design?

[Nat] The difference between a void slot and one with a return value is
that in the latter case, the signal needs a combiner to figure out what
to do with multiple returns from multiple slots. See:

http://www.boost.org/doc/html/ch06s02.html#id2520177

I haven't actually tried your example, but it looks to me as though the
default combiner isn't working for you. But then you probably want
something other than the default anyway -- unless you don't care about
the values returned by your slots -- in which case why not use void
slots?


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