Zeljko Vrba
Hi!
I would like to use mpl to generate code along the following lines (I'm trying to build a reusable library for data processing in a 'pipelined' fashion):
// Arg1 and Arg2 are instances of 'stages' providing results to this // stage. F is the function taking as arguments const Arg1::result_type& // and const Arg2::result_type&. template
struct stage_2 { ~ typedef Result result_type; ~ Result current_; ~ F f_; ~ Arg1 input1_; ~ Arg2 input2_;
~ stage_2(F f, Arg1 a1, Arg2 a2) : f_(f), input1_(a1), input2_(a2) { }
~ const Result &operator() { ~ current_ = f_(input1_(), input2_()); ~ return current_; ~ } };
The question: is it possible not to write manually separate stage_0, stage_1, stage_2, ... for stages taking as input results from the previous 0, 1, 2, ... stages?
I don't understand yet. What is the difference between stage_1 and stage_2? Fewer arguments in stage_1?
== Actually, what I'm trying to design:
S1 -> S2 -> S3 -> .. -> Sk -> ..-> Sn ~ \_______________/
This is just a rough sketch; in the bottom line the arrow goes from S2 to Sk. Each stage (S'es in the diagram) provides input to its 'children'.
Why don't you show an example using three or four handwritten "stages;" then we can consider how the code might be generated. -- Dave Abrahams Boost Consulting www.boost-consulting.com