CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/PhysicsTools/Utilities/interface/Composition.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_Utilities_Composition_h
00002 #define PhysicsTools_Utilities_Composition_h
00003 #include <boost/static_assert.hpp>
00004 
00005 namespace funct {
00006   template<typename A, typename B>
00007   struct CompositionStruct { 
00008     CompositionStruct(const A & a, const B & b) : _1(a), _2(b) { }
00009     double operator()() const {
00010       return _1(_2());
00011     }
00012     operator double() const {
00013       return _1(_2());
00014     }
00015     double operator()(double x) const {
00016       return _1(_2(x));
00017     }
00018     double operator()(double x, double y) const {
00019       return _1(_2(x, y));
00020     }
00021     A _1; 
00022     B _2;
00023   };
00024 
00025   template<typename A, typename B>
00026   struct Composition {
00027     typedef CompositionStruct<A, B> type;
00028     static type compose(const A& a, const B b) { return type(a, b); }
00029   };
00030 
00031   template<typename A, typename B>
00032   inline typename funct::Composition<A, B>::type compose(const A& a, const B& b) {
00033     return funct::Composition<A, B>::compose(a, b);
00034   }
00035 
00036 }
00037 
00038 
00039 #endif