Boost logo

Boost :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-06-30 13:49:16


On Wednesday 30 June 2004 11:14 am, Neal Coombes wrote:
> However, I would venture to claim that a signal being called without any
> slots is not a rare case. In fact I'd guess that might be the most
> likely case. Certainly, as a library writer, I cannot assume that all
> the signals I provide to my users are going to be used in every
> application.
>
> My suggestion is to provide a default combiner that does the bare
> minimum, just call the slots:
>
> namespace boost {
> struct default_combiner {
> typedef void result_type;
>
> template<typename InputIterator>
> result_type operator()(InputIterator first,
> InputIterator last) const
> {
> while (first != last)
> *first++;
> }
> };
> }
>
> I believe this would solve the problem without restricting use of
> default signals to objects with default constructors, or to signals with
> at least one slot connected.

If you don't want to get any results back, just specify the return type of the
slots as void, e.g., change

  boost::signal<int(int, int)> s;

to

  boost::signal<void(int, int)> s;

        Doug


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