ThePEG  1.8.0
TemplateTools.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // TemplateTools.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 2006-2011 David Grellscheid, Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef Template_Tools_H
10 #define Template_Tools_H
11 
17 namespace ThePEG {
18 
20 template <int v>
21 struct Int2Type
22 {
23  enum { value = v };
24 };
25 
27 struct DummyType {};
28 
30 template <typename T, typename U>
31 struct BinaryOpTraits;
32 
35 template <>
36 struct BinaryOpTraits<double,double> {
38  typedef double MulT;
41  typedef double DivT;
42 };
43 
44 template <>
45 struct BinaryOpTraits<long double, long double> {
47  typedef long double MulT;
50  typedef long double DivT;
51 };
52 
53 template <>
54 struct BinaryOpTraits<int,int> {
56  typedef int MulT;
59  typedef int DivT;
60 };
61 
64 enum ImplSelector { Dimensioned, Standard };
66 
69 
72 
73 
75 template <typename T>
76 struct TypeTraits
77 {
79  enum { hasDimension = false };
81  typedef StandardT DimType;
83  static const double baseunit;
84 };
85 
87 template<typename T>
88 const double TypeTraits<T>::baseunit = T(1);
89 
90 }
91 
92 #endif
static const double baseunit
Base unit.
Definition: TemplateTools.h:83
Conversion between integers and types.
Definition: TemplateTools.h:21
Dummy type for ambiguous function signatures.
Definition: TemplateTools.h:27
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
Int2Type< Dimensioned > DimensionT
Typedef for dimensioned types.
Definition: TemplateTools.h:68
ImplSelector
Selection mechanism for type-dependent implementations.
Definition: TemplateTools.h:65
StandardT DimType
Implementation selector.
Definition: TemplateTools.h:81
Type traits for built-in types.
Definition: TemplateTools.h:76
Int2Type< Standard > StandardT
Typedef for non-dimensioned types.
Definition: TemplateTools.h:71
BinaryOpTraits should be specialized with typdefs called MulT and DivT which gives the type resulting...
Definition: PhysicalQty.h:239