Boost logo

Boost Users :

Subject: Re: [Boost-users] [signals] Chaining signals
From: Nat Goodspeed (nat_at_[hidden])
Date: 2009-03-13 13:33:10


Remko Tronçon wrote:

> Is it possible to 'chain' boost signals? I.e., connect signal a to
> signal b, such that whenever signal a fires, all slots of signal b are
> called.

#include <boost/signals.hpp>
#include <boost/bind.hpp>
#include <iostream>

void gotit()
{
     std::cout << "Received the signal\n";
}

int main(int argc, char *argv[])
{
     typedef boost::signal<void()> signal_type;
     signal_type first;
     signal_type second;
     first.connect(boost::bind(boost::ref(second)));
     second.connect(boost::bind(gotit));
     first();
     return 0;
}


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