Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-03-07 20:31:54

On Sunday 07 March 2004 04:28 pm, E. Gladyshev wrote:
> Does boost::signals have a public enumeration interface (like iterator
> concept) that can be used for accessing individual slots?

If you're looking for a way to access the slots (e.g., to see the underlying
boost::function objects), there is no such interface, but...

> There is some mention of it in the "Slot Call Iterator" section but not
> much detailed.
> For instance, what I'd like is to call a slot and depending on the result
> call some other slot.

This you can do. The slot call iterator is just an iterator, but the
dereference operator actually invokes the slot. So, for instance, if you'd
like to keep calling slots until one of them becomes true, you might write a
combiner like this:

struct until_true {
  typedef bool result_type;

  template<typename InputIterator>
    bool operator()(InputIterator first, InputIterator last)
      while (first != last) {
        if (*first) return true;
      return false;

> A related question is if I have an instance of boost::signals::connection,
> is it possible to get an access to the slot that this connection is
> referencing?


Back when Signals was designed, there was no way to use this capability
because boost::function objects were entirely opaque. Now they're a bit less
opaque (in CVS, at least, because of operator==), so this could be seen as
more of a hindrance.


Boost list run by bdawes at, gregod at, cpdaniel at, john at