File indexing completed on 2024-04-06 12:24:19
0001 #ifndef PhysicsTools_Utilities_Product_h
0002 #define PhysicsTools_Utilities_Product_h
0003
0004 namespace funct {
0005 template <typename A, typename B>
0006 struct ProductStruct {
0007 ProductStruct(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(x) * _2(x); }
0011 double operator()(double x, double y) const { return _1(x, y) * _2(x, y); }
0012 A _1;
0013 B _2;
0014 };
0015
0016 template <typename A, typename B>
0017 struct Product {
0018 typedef ProductStruct<A, B> type;
0019 static type combine(const A& a, const B& b) { return type(a, b); }
0020 };
0021
0022 template <typename A, typename B>
0023 inline typename Product<A, B>::type operator*(const A& a, const B& b) {
0024 return Product<A, B>::combine(a, b);
0025 }
0026 }
0027
0028 #endif