30 using phys::units::io::operator<<;
41 template <
int N,
typename T>
42 auto constexpr static_pow([[maybe_unused]] T x) {
43 if constexpr (N == 0) {
45 }
else if constexpr (N > 0) {
46 return x * static_pow<N - 1, T>(x);
48 return 1 / static_pow<-N, T>(x);
66 using phys::units::io::operator<<;
106 template <
typename DimFrom,
typename DimTo>
107 auto constexpr conversion_factor_HEP_to_SI() {
108 static_assert(DimFrom::dim1 == 0 && DimFrom::dim2 == 0 && DimFrom::dim3 == 0 &&
109 DimFrom::dim4 == 0 && DimFrom::dim5 == 0 && DimFrom::dim6 == 0 &&
111 "must be a pure HEP type");
114 DimTo::dim4 == 0 && DimTo::dim5 == 0 && DimTo::dim6 == 0 && DimTo::dim7 == 0,
115 "conversion possible only into L, M, T dimensions");
117 int constexpr e = DimFrom::dim8;
119 int constexpr l = DimTo::dim1;
120 int constexpr m = DimTo::dim2;
121 int constexpr t = DimTo::dim3;
124 int constexpr q = -m - t;
125 static_assert(q == l + e - 2 * m,
"HEP/SI dimension mismatch!");
127 return static_pow<-e>(constants::hBarC) * static_pow<p>(constants::hBar) *
128 static_pow<q>(constants::c);
131 template <
typename DimFrom>
132 auto constexpr conversion_factor_SI_to_HEP() {
133 static_assert(DimFrom::dim4 == 0 && DimFrom::dim5 == 0 && DimFrom::dim6 == 0 &&
134 DimFrom::dim7 == 0 && DimFrom::dim8 == 0,
135 "must be pure L, M, T type");
137 int constexpr l = DimFrom::dim1;
138 int constexpr m = DimFrom::dim2;
139 int constexpr t = DimFrom::dim3;
141 int constexpr p = -m;
142 int constexpr q = m + t;
143 int constexpr e = m - t - l;
145 return static_pow<e>(constants::hBarC) * static_pow<p>(constants::hBar) *
146 static_pow<q>(constants::c);
149 template <
typename DimTo,
typename DimFrom>
151 return conversion_factor_HEP_to_SI<DimFrom, DimTo>() * q;
154 template <
typename DimFrom>
156 return conversion_factor_SI_to_HEP<DimFrom>() * q;
175 QUANTITY_DEFINE_SCALING_LITERALS(eV,
hepenergy_d, 1)
186 using namespace units;
187 using namespace units::si;
191 using phys::units::io::operator<<;
We could drag dimensions around individually, but it's much more convenient to package them...
IO for compile-time quantity library.
Zero-overhead dimensional analysis and unit/quantity manipulation and conversion. ...
Extension of the phys::units package.
class "quantity" is the heart of the library.
`, since they are used everywhere as integral part of the framework.
Constants are defined with static units, based on the package (namespace) phys::units, imported in PhysicsUnits.hpp.
SI units as used mainly in CORSIKA8 as basedline.
constexpr X magnitude(quantity< DX, X > const &q)
quantity's magnitude.