Boost logo

Boost :

From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2002-10-14 16:31:56


On Mon, 14 Oct 2002 graham.shanks_at_[hidden] wrote:
[snip example]
> The solution to get the expected (by me) behaviour is to use
> boost::bind, i.e.
>
> sig.connect(boost::bind(&EventCounter::operator(), &eventCounter));

You might also consider deriving EventCounter from
boost::signals::trackable or using boost::signals::scoped_connection, so
that the Signals reference to eventCounter doesn't outlive the
eventCounter object.

> Assuming that my analysis is correct, might I suggest than the
> documentation be extended to:
>
> a) add a comment in the Connection Management section of signalN to
> state that a copy is made of the slot (or should this be that it is
> unspecified if a copy of the slot is made?)
>
> b) Add an example to the tutorial pointing out this behaviour (you may
> freely use the example above)

Sure! Thanks for the example.

> Might I further suggest that mention is made of the observer pattern
> in the introduction to the library - many programmers are more
> familiar with that terminology than signals & slots.

This paradigm has way too many names. I'll mention the observer pattern in
the introduction.

> I also found it surprising that the copy was nested to a depth of 7,
> but that may just be a consequence of the compiler I'm using (MSVC 6.0
> SP5).

The unfortunate result of way too many workarounds. The inliner should
take care of most of the overhead, but it makes debugging abominable.

> BTW thanks Doug for a great library. I'm busy replacing my own
> observer classes with the signal library - which will finally allow me
> to replace my home-brewed callback library with boost::function.

Thank you!

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk