#ifndef COMPOSER_FG1X_G2X #define COMPOSER_FG1X_G2X //Compose three functions f, g1, and g2 like this: f(g1(x), g2(x)) template class composer_fg1x_g2x { F f; G1 g1; G2 g2; public: typedef typename G1::argument_type argument_type; typedef typename F::result_type result_type; composer_fg1x_g2x(const F& initial_f, const G1& initial_g1, const G2& initial_g2) : f(initial_f), g1(initial_g1), g2(initial_g2) {} result_type operator()(const typename G1::argument_type& x) const { return f(g1(x), g2(x)); } }; template inline composer_fg1x_g2x compose2(const F& f, const G1& g1, const G2& g2 ) { return composer_fg1x_g2x(f, g1, g2); } #endif