82 T unit_temperature = 1,
85 :
s(1 / unit_time),
m(1 / unit_length),
kg(1 / unit_mass),
A(1 / unit_current),
86 K(1 / unit_temperature),
mol(1 / unit_qte),
cd(1 / unit_lumint),
s_inv(unit_time),
102 using acc_t =
decltype(T{} * Tret{} *
double{});
120 template<Unit u,
class Tret = T>
121 constexpr Tret
get() const noexcept {
125 pow_constexpr_fast_inv<u.dim.second>(Tacc(
s), Tacc(
s_inv))
126 * pow_constexpr_fast_inv<u.dim.metre>(Tacc(
m), Tacc(
m_inv))
127 * pow_constexpr_fast_inv<u.dim.kilogram>(Tacc(
kg), Tacc(
kg_inv))
128 * pow_constexpr_fast_inv<u.dim.ampere>(Tacc(
A), Tacc(
A_inv))
129 * pow_constexpr_fast_inv<u.dim.kelvin>(Tacc(
K), Tacc(
K_inv))
130 * pow_constexpr_fast_inv<u.dim.mole>(Tacc(
mol), Tacc(
mol_inv))
131 * pow_constexpr_fast_inv<u.dim.candela>(Tacc(
cd), Tacc(
cd_inv))
132 * Tacc(u.si_factor));
138 template<Unit u,
class Tret = T>
139 constexpr Tret
to() const noexcept {
140 return get<
upow(u, -1), Tret>();
145 template<
class Tret = T,
class Tu>
150 ipow(Tacc(
s), u.dim.second, Tacc(
s_inv)) * ipow(Tacc(
m), u.dim.metre, Tacc(
m_inv))
151 * ipow(Tacc(
kg), u.dim.kilogram, Tacc(
kg_inv))
152 * ipow(Tacc(
A), u.dim.ampere, Tacc(
A_inv))
153 * ipow(Tacc(
K), u.dim.kelvin, Tacc(
K_inv))
155 * ipow(Tacc(
cd), u.dim.candela, Tacc(
cd_inv)) * Tacc(u.si_factor));
160 template<
class Tret = T,
class Tu>
166 template<
class Tret = T,
class Tu>
172 template<
class Tret = T,
class Tu>
A physical unit as a value: its SI dimension and its magnitude in SI base units.
constexpr Tret get(Unit< Tu > u, int power) const noexcept
constexpr Tret to(Unit< Tu > u) const noexcept
Inverse of get(u).
constexpr UnitSystem(T unit_time=1, T unit_length=1, T unit_mass=1, T unit_current=1, T unit_temperature=1, T unit_qte=1, T unit_lumint=1)
Construct a new UnitSystem from either supplied base units or SI by default.
decltype(f64{} *Tret{} *double{}) acc_t
constexpr Tret to() const noexcept
constexpr Tret get() const noexcept
Value of the compile-time unit u in this system.
constexpr Tret get(Unit< Tu > u) const noexcept
constexpr Tret to(Unit< Tu > u, int power) const noexcept
Inverse of get(u, power).
namespace containing the units library
constexpr Unit< T > upow(Unit< T > u, int n) noexcept
Integer power of a unit.
A unit: its dimension and its magnitude expressed in SI base units, in precision Tscal.
Integer powers with a supplied reciprocal, so a negative exponent never divides.
constexpr T pow_constexpr_fast_inv(T a, T a_inv) noexcept
Constexpr power expansion function with supplied inverse for negative values.
constexpr T ipow(T a, int n, T a_inv) noexcept
Runtime twin of pow_constexpr_fast_inv, for an exponent only known at run time.