Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:26

0001 #ifndef PhysicsTools_Utilities_Composition_h
0002 #define PhysicsTools_Utilities_Composition_h
0003 
0004 namespace funct {
0005   template <typename A, typename B>
0006   struct CompositionStruct {
0007     CompositionStruct(const A& a, const B& b) : _1(a), _2(b) {}
0008     double operator()() const { return _1(_2()); }
0009     operator double() const { return _1(_2()); }
0010     double operator()(double x) const { return _1(_2(x)); }
0011     double operator()(double x, double y) const { return _1(_2(x, y)); }
0012     A _1;
0013     B _2;
0014   };
0015 
0016   template <typename A, typename B>
0017   struct Composition {
0018     typedef CompositionStruct<A, B> type;
0019     static type compose(const A& a, const B& b) { return type(a, b); }
0020   };
0021 
0022   template <typename A, typename B>
0023   inline typename funct::Composition<A, B>::type compose(const A& a, const B& b) {
0024     return funct::Composition<A, B>::compose(a, b);
0025   }
0026 
0027 }  // namespace funct
0028 
0029 #endif