binary_compose.hh
Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  * $Id: binary_compose.hh 957 2005-03-07 16:01:20Z sjoyeux $
00003  */
00004 #ifndef UTILMM_FUNCTIONAL_BINARY_COMPOSE_HEADER
00005 # define UTILMM_FUNCTIONAL_BINARY_COMPOSE_HEADER
00006 
00007 # include <functional>
00008 
00009 #include "utilmm/functional/arg_traits.hh"
00010 
00011 namespace utilmm {
00012   
00034   template<class BinaryFun, class UnaryFun1, class UnaryFun2>
00035   struct binary_compose_2
00036     :public std::binary_function<typename UnaryFun1::argument_type,
00037                                  typename UnaryFun2::argument_type,
00038                                  typename BinaryFun::result_type> {
00039   private:
00040     BinaryFun bin_fn;
00041     UnaryFun1 fun_1;
00042     UnaryFun2 fun_2;    
00043 
00044     typedef typename 
00045       arg_traits<typename UnaryFun1::argument_type>::type first_arg;
00046     typedef typename 
00047       arg_traits<typename UnaryFun2::argument_type>::type second_arg;
00048 
00049   public:
00064     binary_compose_2(BinaryFun const &bin, UnaryFun1 const &one,
00065                      UnaryFun2 const &two)
00066       :bin_fn(bin), fun_1(one), fun_2(two) {}
00067     
00077     typename BinaryFun::result_type operator()(first_arg a, second_arg b)
00078       const {
00079       return bin_fn(fun_1(a), fun_2(b));
00080     }
00081 
00082   }; // class utilmm::binary_compose_2<>
00083 
00100   template<class Bin, class Fun1, class Fun2>
00101   binary_compose_2<Bin, Fun1, Fun2> compose2_2(Bin const &f, Fun1 const &a,
00102                                                Fun2 const &b) {
00103     return binary_compose_2<Bin, Fun1, Fun2>(f, a, b);
00104   }
00105 
00106 } // namespace utilmm
00107 
00108 #endif // UTILMM_FUNCTIONAL_BINARY_COMPOSE_HEADER
00109 


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Mon Oct 6 2014 03:17:01