template alt_opt foo() { ... if(x) { /* Application of F.1.b */ T & t1 = p1(); //use t1 /* Application of F.1.b */ T & t2 = p2(); //use t2 /* Application of F.1.a */ alt_opt o(q1()); //Do 1 //Application of F.2.a */ return bar1(o, other_relevant_parameters_here); } if(y) { /* Application of F.1.a */ alt_opt o(q2()); //Do 2 //Application of F.2.a */ return bar1(o, other_relevant_parameters_here); } } /* Application of F.2.b */ template alt_opt bar1(o, other_relevant_parameters_here) { //Do 3: use o here ... switch(cond) { case a: { /* Application of F.1.a */ alt_opt o1(foo1()); //Application of F.2.a */ return bar2(o1, other_relevant_parameters_here); } case b: { /* Application of F.1.a */ alt_opt o1(foo2()); //Application of F.2.a */ return bar2(o1, other_relevant_parameters_here); } //likewise for c,d,e default: { /* Application of F.1.a */ alt_opt o1; //Application of F.2.a */ return bar2(o1, other_relevant_parameters_here); } } } /* Application of F.2.b */ template alt_opt bar2(o, other_relevant_parameters_here) { if(o) { //Do 4. } /* Application of F.1.a */ alt_opt o1(foo8()); //Application of F.2.a */ return bar3(o1, other_relevant_parameters_here); } /* Application of F.2.b */ template alt_opt bar3(o, other_relevant_parameters_here) { //Do 5. return o1; }