npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
LongerType.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_LONGERTYPE_HH_
2 #define NPSTAT_LONGERTYPE_HH_
3 
4 /*!
5 // \file LongerType.hh
6 //
7 // \brief Compile-time deduction of an appropriate numeric type for
8 // simple algebraic operations
9 //
10 // Author: I. Volobouev
11 //
12 // September 2019
13 */
14 
15 #include <type_traits>
16 
17 namespace npstat {
18  template <class T1, class T2>
19  struct LongerType
20  {
21  typedef typename std::common_type<T1,T2>::type type;
22  };
23 
24  template <class T1>
25  struct LongerType<T1,T1>
26  {
27  typedef T1 type;
28  };
29 
30  template<unsigned I1, unsigned I2>
31  struct BiggerUInt
32  {
33  enum {value = I1 > I2 ? I1 : I2};
34  };
35 }
36 
37 #endif // NPSTAT_LONGERTYPE_HH_
Definition: AbsArrayProjector.hh:14
Definition: LongerType.hh:32
Definition: LongerType.hh:20