Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-03-09 11:30:15


On Monday 08 March 2004 10:46 pm, E. Gladyshev wrote:
> I guess I can try something like this:
[snip]
> struct capture_wrapper
> {
> signals::slot_type s_;
>
> capture_wrapper( slot s ) : s_(s) {}
>
> bool operator()( event e )
> {
> //how do I make the call?
> s_(e); //is it ok?
> return true; //stop propagation
> }
> }
[snip]

I suggest making capture_wrapper a function object wrapper, not a slot_type
(slot_types aren't actually invocable as function objects):

template<typename F>
  struct capture_wrapper
  {
    F f;

    capture_wrapper(F f) : f(f) {}
  
    bool operator()(event e)
    {
      f(e);
      return true;
    }
  };

> I also need an efficient way for accessing slots randomly.
> For instance some of the Win32 listbox messages
> have item indexes. I'd like to implement each
> item as a slot, but I need a way to access
> the slots based on the item index, so I could call
> just the right slot.
> listboxes can contain a lot of items so propagating
> the messages to all items is not an option.

That'd be a much bigger change to Signals. For one, we'd be breaking the
logarithmic complexity of inserting a new element in a particular group.

        Doug


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