Boost logo

Boost Users :

From: Allan Douglas (allandouglas_at_[hidden])
Date: 2007-02-15 01:02:30


Hello,

I'm using Boost.Signals to implement Deferreds
(http://twistedmatrix.com/projects/core/documentation/howto/defer.html).
An important feature of Deferreds is the hability to chain callbacks.

Speaking of Signals, I want a way to call slots using args from
previous slots calls.

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?

Thanks,
Allan Douglas


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