Boost logo

Boost Users :

From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2007-02-15 07:58:15


-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Allan Douglas
Sent: Thursday, February 15, 2007 1:03 AM
To: boost-users_at_[hidden]
Subject: [Boost-users] [signals] Chaining slots

For example:

float square(float x) { return x*x; }
float sum1(float x) { return x+1; }

boost::signal<float (float x)> sig;

/* do some magic here */

sig.connect(&square);
sig.connect(&sum1);
sig.connect(&square);

// sig(2) should call square(sum1(square(2)))
std::cout << sig(2) << std::endl;

I want the example to output 25 ( (2**2)+1)**2)

Any ideas on how to implement this?

[Nat] Sounds to me like a custom Combiner.

http://boost.org/doc/html/signals/s06.html#id2739686


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