unary_compose.hh
Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  * $Id: unary_compose.hh 957 2005-03-07 16:01:20Z sjoyeux $
00003  */
00004 #ifndef UTILMM_FUNCTIONAL_UNARY_COMPOSE_HEADER
00005 # define UTILMM_FUNCTIONAL_UNARY_COMPOSE_HEADER
00006 
00007 # include <functional>
00008 
00009 #include "utilmm/functional/arg_traits.hh"
00010 
00011 namespace utilmm {
00012   
00030   template<class UnaryFun1, class UnaryFun2>
00031   struct unary_compose
00032     :public std::unary_function<typename UnaryFun2::argument_type,
00033                                  typename UnaryFun1::result_type> {
00034   private:
00035     UnaryFun1 fun_1;
00036     UnaryFun2 fun_2;    
00037 
00038     typedef typename 
00039       arg_traits<typename UnaryFun2::argument_type>::type arg_param;
00040 
00041   public:
00055     unary_compose(UnaryFun1 const &one, UnaryFun2 const &two)
00056       :fun_1(one), fun_2(two) {}
00057     
00066     typename UnaryFun1::result_type operator()(arg_param x)
00067       const {
00068       return fun_1(fun_2(x));
00069     }
00070 
00071   }; // class utilmm::binary_compose_2<>
00072 
00087   template<class Fun1, class Fun2>
00088   unary_compose<Fun1, Fun2> compose1(Fun1 const &f, Fun2 const &g) {
00089     return unary_compose<Fun1, Fun2>(f, g);
00090   }
00091 
00092 } // namespace utilmm
00093 
00094 #endif // UTILMM_FUNCTIONAL_BINARY_COMPOSE_HEADER
00095 


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Wed Sep 16 2015 07:05:43