|
|
|||
File indexing completed on 2026-08-06 09:38:20
0001 // -*- C++ -*- 0002 // 0003 // TemplateTools.h is a part of ThePEG - Toolkit for HEP Event Generation 0004 // Copyright (C) 2006-2019 David Grellscheid, Leif Lonnblad 0005 // 0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details. 0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 0008 // 0009 #ifndef Template_Tools_H 0010 #define Template_Tools_H 0011 0012 #include <type_traits> 0013 0014 /** 0015 * @file TemplateTools.h 0016 * Useful template machinery. Based on Alexandrescu, "Modern C++ Design". 0017 */ 0018 0019 namespace ThePEG { 0020 0021 /// Conversion between integers and types. 0022 template <int v> 0023 struct Int2Type 0024 { 0025 enum { value = v }; 0026 }; 0027 0028 /// Dummy type for ambiguous function signatures. 0029 struct DummyType {}; 0030 0031 /** @endcond */ 0032 0033 /// Selection mechanism for type-dependent implementations. 0034 enum ImplSelector { Dimensioned, Standard, Enumerated }; 0035 0036 /// Typedef for dimensioned types. 0037 typedef Int2Type<Dimensioned> DimensionT; 0038 0039 /// Typedef for non-dimensioned types. 0040 typedef Int2Type<Standard> StandardT; 0041 0042 /// Typedef for non-dimensioned types. 0043 typedef Int2Type<Enumerated> EnumT; 0044 0045 0046 /// Type traits for built-in types 0047 template <typename T> 0048 struct TypeTraits 0049 { 0050 /// Boolean flag. Is true for physical quantities. 0051 enum { hasDimension = false }; 0052 /// Implementation selector 0053 typedef StandardT DimType; 0054 /// Base unit for arithmetic types 0055 // construction with extra U type is necessary to make 0056 // enable_if work before concepts are supported properly 0057 template <typename U = T> 0058 static constexpr typename 0059 std::enable_if< (std::is_arithmetic<U>::value && 0060 std::is_same<U, T>::value), U>::type 0061 baseunit() 0062 { return static_cast<U>(1); } 0063 }; 0064 0065 } 0066 0067 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|