Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-04-10 14:06:28

On Wednesday 10 April 2002 02:17 pm, you wrote:
> Is there a way to chain two functions? Yes, we can use boost::compose (or
> nested boost::bind) to "compose" two functions, but we can't just chain
> them.

Lambda library (accepted, but not yet included in Boost) allows you to
sequence function calls, e.g.,

  bind(f1), bind(f2)

The comma operator is the sequencing operator, so the result of calling f1
will be ignored and the result of f2 would be returned.

And if you want to return the values in a tuple:

  bind(construct<tuple<int, float> >(), bind(f1), bind(f2))

> Let me know what you think about it. Also, I don't have a clue about
> internals of boost::function, so I apologize in advance if I've overlooked
> something.
> Giovanni Bajo

I think it's a good idea, and it has been requested before. You don't even
need to know anything about the internals of boost::function, because
function object chaining need only be based on function objects and not on
boost::function specifically.


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