thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
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-2019 David Grellscheid, Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 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 
12 #include <type_traits>
13 
19 namespace ThePEG {
20 
22 template <int v>
23 struct Int2Type
24 {
25  enum { value = v };
26 };
27 
29 struct DummyType {};
30 
33 enum ImplSelector { Dimensioned, Standard, Enumerated };
35 
38 
41 
44 
45 
47 template <typename T>
48 struct TypeTraits
49 {
51  enum { hasDimension = false };
53  typedef StandardT DimType;
55  // construction with extra U type is necessary to make
56  // enable_if work before concepts are supported properly
57  template <typename U = T>
58  static constexpr typename
59  std::enable_if< (std::is_arithmetic<U>::value &&
60  std::is_same<U, T>::value), U>::type
62  { return static_cast<U>(1); }
63 };
64 
65 }
66 
67 #endif
Conversion between integers and types.
Definition: TemplateTools.h:23
Dummy type for ambiguous function signatures.
Definition: TemplateTools.h:29
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
Int2Type< Enumerated > EnumT
Typedef for non-dimensioned types.
Definition: TemplateTools.h:43
Int2Type< Dimensioned > DimensionT
Typedef for dimensioned types.
Definition: TemplateTools.h:37
ImplSelector
Selection mechanism for type-dependent implementations.
Definition: TemplateTools.h:34
StandardT DimType
Implementation selector.
Definition: TemplateTools.h:53
Type traits for built-in types.
Definition: TemplateTools.h:48
Int2Type< Standard > StandardT
Typedef for non-dimensioned types.
Definition: TemplateTools.h:40
static constexpr std::enable_if<(std::is_arithmetic< U >::value &&std::is_same< U, T >::value), U >::type baseunit()
Base unit for arithmetic types.
Definition: TemplateTools.h:61