test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Sum.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Sum_h
2 #define PhysicsTools_Utilities_Sum_h
4 #include <boost/static_assert.hpp>
5 
6 namespace funct {
7  template<typename A, typename B>
8  struct SumStruct {
9  SumStruct(const A & a, const B & b) : _1(a), _2(b) { }
10  double operator()() const {
11  return _1() + _2();
12  }
13  operator double() const {
14  return _1() + _2();
15  }
16  double operator()(double x) const {
17  return _1(x) + _2(x);
18  }
19  double operator()(double x, double y) const {
20  return _1(x, y) + _2(x, y);
21  }
22  A _1;
23  B _2;
24  };
25 
26  template<typename A, typename B>
27  struct Sum {
29  static type combine(const A& a, const B& b) { return type(a, b); }
30  };
31 
32  template<typename A, typename B>
33  inline typename Sum<A, B>::type operator+(const A& a, const B& b) {
34  return Sum<A, B>::combine(a, b);
35  }
36 
37 }
38 
39 #endif
Sum< A, B >::type operator+(const A &a, const B &b)
Definition: Sum.h:33
double operator()(double x, double y) const
Definition: Sum.h:19
double operator()(double x) const
Definition: Sum.h:16
SumStruct(const A &a, const B &b)
Definition: Sum.h:9
static type combine(const A &a, const B &b)
Definition: Sum.h:29
SumStruct< A, B > type
Definition: Sum.h:28
double b
Definition: hdecay.h:120
double operator()() const
Definition: Sum.h:10
double a
Definition: hdecay.h:121
Definition: Sum.h:27
Definition: DDAxes.h:10