#ifndef COMPOSER_FGX1_GX2 #define COMPOSER_FGX1_GX2 #include //for binary_function using namespace std; //Compose the functions f(g(x1), g(x2)). template class composer_fgx1_gx2: public binary_function { F f; G g; public: composer_fgx1_gx2(const F& initial_f, const G& initial_g) : f(initial_f), g(initial_g) {} typename F::result_type operator()( const typename G::argument_type& x1, const typename G::argument_type& x2) { return f(g(x1), g(x2)); } }; template inline composer_fgx1_gx2 compose_fgx1_gx2( const F& initial_f, const G& initial_g) { return composer_fgx1_gx2(initial_f, initial_g); } #endif