Boost logo

Boost Users :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-04-16 08:51:17


On Wednesday 16 April 2003 08:26 am, Jesper Bojesen wrote:
> My problem is that the object signalled is not the same object that I
> subscribed to the signal.
>
> Is this really what was inteded ?

Yes.

> Is the any rationale behind this behaviour ?

Yes. In STL, function objects are copied around at will, so Signals picks up
that part of the function object concept.

If you want Signals to keep a reference to a function object (instead of
making a copy), use boost::ref:
  sig.connect(boost::ref(hello));

        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