forked from mpusz/mp-units
Rename as_magnitude<...>() to mag<...>()
This is easier to write and to read.
This commit is contained in:
@@ -39,8 +39,7 @@ inline constexpr bool compatible_units<exponent_list<Es...>, Us...> = (UnitOf<Us
|
||||
template<Unit... Us, typename... Es>
|
||||
constexpr Magnitude auto derived_mag(exponent_list<Es...>)
|
||||
{
|
||||
return (as_magnitude<1>() * ... *
|
||||
pow<ratio{Es::num, Es::den}>(Us::mag / dimension_unit<typename Es::dimension>::mag));
|
||||
return (mag<1>() * ... * pow<ratio{Es::num, Es::den}>(Us::mag / dimension_unit<typename Es::dimension>::mag));
|
||||
}
|
||||
|
||||
template<DerivedDimension D, Unit... Us>
|
||||
|
||||
@@ -37,7 +37,7 @@ constexpr auto magnitude_text()
|
||||
{
|
||||
constexpr auto exp10 = extract_power_of_10(M);
|
||||
|
||||
constexpr Magnitude auto base = M / pow<exp10>(as_magnitude<10>());
|
||||
constexpr Magnitude auto base = M / pow<exp10>(mag<10>());
|
||||
constexpr Magnitude auto num = numerator(base);
|
||||
constexpr Magnitude auto den = denominator(base);
|
||||
static_assert(base == num / den, "Printing rational powers, or irrational bases, not yet supported");
|
||||
@@ -72,7 +72,7 @@ constexpr auto magnitude_text()
|
||||
template<Unit U, Magnitude auto M, std::size_t SymbolLen>
|
||||
constexpr auto prefix_or_magnitude_text()
|
||||
{
|
||||
if constexpr (M == as_magnitude<1>()) {
|
||||
if constexpr (M == mag<1>()) {
|
||||
// no ratio/prefix
|
||||
return basic_fixed_string("");
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace units {
|
||||
template<typename Rep, typename Period>
|
||||
struct quantity_like_traits<std::chrono::duration<Rep, Period>> {
|
||||
private:
|
||||
static constexpr auto mag = as_magnitude<ratio(Period::num, Period::den)>();
|
||||
static constexpr auto mag = mag<ratio(Period::num, Period::den)>();
|
||||
public:
|
||||
using dimension = isq::si::dim_time;
|
||||
using unit = downcast_unit<dimension, mag>;
|
||||
@@ -48,7 +48,7 @@ struct clock_origin : point_origin<isq::si::dim_time> {};
|
||||
template<typename C, typename Rep, typename Period>
|
||||
struct quantity_point_like_traits<std::chrono::time_point<C, std::chrono::duration<Rep, Period>>> {
|
||||
private:
|
||||
static constexpr auto mag = as_magnitude<ratio(Period::num, Period::den)>();
|
||||
static constexpr auto mag = mag<ratio(Period::num, Period::den)>();
|
||||
public:
|
||||
using origin = clock_origin<C>;
|
||||
using unit = downcast_unit<typename origin::dimension, mag>;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace units {
|
||||
|
||||
struct one : derived_unit<one> {};
|
||||
struct percent : named_scaled_unit<percent, "%", as_magnitude<ratio(1, 100)>(), one> {};
|
||||
struct percent : named_scaled_unit<percent, "%", mag<ratio(1, 100)>(), one> {};
|
||||
|
||||
/**
|
||||
* @brief Dimension one
|
||||
|
||||
@@ -596,7 +596,7 @@ constexpr auto common_magnitude(magnitude<H1, T1...>, magnitude<H2, T2...>)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// `as_magnitude()` implementation.
|
||||
// `mag()` implementation.
|
||||
|
||||
// Sometimes we need to give the compiler a "shortcut" when factorizing large numbers (specifically, numbers whose
|
||||
// _first factor_ is very large). If we don't, we can run into limits on the number of constexpr steps or iterations.
|
||||
@@ -647,7 +647,7 @@ inline constexpr auto prime_factorization_v = prime_factorization<N>::value;
|
||||
*/
|
||||
template<ratio R>
|
||||
requires(R.num > 0)
|
||||
constexpr Magnitude auto as_magnitude()
|
||||
constexpr Magnitude auto mag()
|
||||
{
|
||||
return detail::prime_factorization_v<R.num> / detail::prime_factorization_v<R.den>;
|
||||
}
|
||||
@@ -659,7 +659,7 @@ template<ratio Base, ratio Pow>
|
||||
requires(Base.num > 0)
|
||||
constexpr Magnitude auto mag_power()
|
||||
{
|
||||
return pow<Pow>(as_magnitude<Base>());
|
||||
return pow<Pow>(mag<Base>());
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -80,7 +80,7 @@ struct same_unit_reference : is_same<typename U1::reference, typename U2::refere
|
||||
* @tparam Symbol a short text representation of the unit
|
||||
*/
|
||||
template<typename Child, basic_symbol_text Symbol>
|
||||
struct named_unit : downcast_dispatch<Child, scaled_unit<as_magnitude<1>(), Child>> {
|
||||
struct named_unit : downcast_dispatch<Child, scaled_unit<mag<1>(), Child>> {
|
||||
static constexpr auto symbol = Symbol;
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ struct prefixed_unit : downcast_dispatch<Child, scaled_unit<P::mag * U::mag, typ
|
||||
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
|
||||
*/
|
||||
template<typename Child>
|
||||
struct derived_unit : downcast_dispatch<Child, scaled_unit<as_magnitude<1>(), Child>> {};
|
||||
struct derived_unit : downcast_dispatch<Child, scaled_unit<mag<1>(), Child>> {};
|
||||
|
||||
/**
|
||||
* @brief A unit with a deduced ratio and symbol
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct kibi : prefix<kibi, "Ki", pow<10>(as_magnitude<2>())> {};
|
||||
struct mebi : prefix<mebi, "Mi", pow<20>(as_magnitude<2>())> {};
|
||||
struct gibi : prefix<gibi, "Gi", pow<30>(as_magnitude<2>())> {};
|
||||
struct tebi : prefix<tebi, "Ti", pow<40>(as_magnitude<2>())> {};
|
||||
struct pebi : prefix<pebi, "Pi", pow<50>(as_magnitude<2>())> {};
|
||||
struct exbi : prefix<exbi, "Ei", pow<60>(as_magnitude<2>())> {};
|
||||
struct zebi : prefix<zebi, "Zi", pow<70>(as_magnitude<2>())> {};
|
||||
struct yobi : prefix<yobi, "Yi", pow<80>(as_magnitude<2>())> {};
|
||||
struct kibi : prefix<kibi, "Ki", pow<10>(mag<2>())> {};
|
||||
struct mebi : prefix<mebi, "Mi", pow<20>(mag<2>())> {};
|
||||
struct gibi : prefix<gibi, "Gi", pow<30>(mag<2>())> {};
|
||||
struct tebi : prefix<tebi, "Ti", pow<40>(mag<2>())> {};
|
||||
struct pebi : prefix<pebi, "Pi", pow<50>(mag<2>())> {};
|
||||
struct exbi : prefix<exbi, "Ei", pow<60>(mag<2>())> {};
|
||||
struct zebi : prefix<zebi, "Zi", pow<70>(mag<2>())> {};
|
||||
struct yobi : prefix<yobi, "Yi", pow<80>(mag<2>())> {};
|
||||
|
||||
} // namespace units::isq::iec80000
|
||||
|
||||
@@ -53,7 +53,7 @@ struct tebibit : prefixed_unit<tebibit, tebi, bit> {};
|
||||
struct pebibit : prefixed_unit<pebibit, pebi, bit> {};
|
||||
struct exbibit : prefixed_unit<exbibit, exbi, bit> {};
|
||||
|
||||
struct byte : named_scaled_unit<byte, "B", as_magnitude<8>(), bit> {};
|
||||
struct byte : named_scaled_unit<byte, "B", mag<8>(), bit> {};
|
||||
|
||||
struct kilobyte : prefixed_unit<kilobyte, si::kilo, byte> {};
|
||||
struct megabyte : prefixed_unit<megabyte, si::mega, byte> {};
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace units::isq::si::fps {
|
||||
struct poundal : named_unit<poundal, "pdl"> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Pound_(force)
|
||||
struct pound_force : named_scaled_unit<pound_force, "lbf", as_magnitude<ratio(32'174'049, 1'000'000)>(), poundal> {};
|
||||
struct pound_force : named_scaled_unit<pound_force, "lbf", mag<ratio(32'174'049, 1'000'000)>(), poundal> {};
|
||||
|
||||
struct kilopound_force : prefixed_unit<kilopound_force, si::kilo, pound_force> {};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ struct thousandth : alias_unit<thou, "thou"> {};
|
||||
|
||||
struct kiloyard : prefixed_unit<kiloyard, si::kilo, yard> {};
|
||||
|
||||
struct nautical_mile : named_scaled_unit<nautical_mile, "nmi", as_magnitude<2'000>(), yard> {};
|
||||
struct nautical_mile : named_scaled_unit<nautical_mile, "nmi", mag<2'000>(), yard> {};
|
||||
|
||||
struct dim_length : isq::dim_length<foot> {};
|
||||
|
||||
|
||||
@@ -35,28 +35,28 @@
|
||||
namespace units::isq::si::fps {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Pound_(mass)
|
||||
struct pound : named_scaled_unit<pound, "lb", as_magnitude<ratio(45'359'237, 100'000'000)>(), si::kilogram> {};
|
||||
struct pound : named_scaled_unit<pound, "lb", mag<ratio(45'359'237, 100'000'000)>(), si::kilogram> {};
|
||||
|
||||
struct dim_mass : isq::dim_mass<pound> {};
|
||||
|
||||
template<UnitOf<dim_mass> U, Representation Rep = double>
|
||||
using mass = quantity<dim_mass, U, Rep>;
|
||||
|
||||
struct grain : named_scaled_unit<grain, "gr", as_magnitude<ratio(1, 7000)>(), pound> {};
|
||||
struct grain : named_scaled_unit<grain, "gr", mag<ratio(1, 7000)>(), pound> {};
|
||||
|
||||
struct dram : named_scaled_unit<dram, "dr", as_magnitude<ratio(1, 256)>(), pound> {};
|
||||
struct dram : named_scaled_unit<dram, "dr", mag<ratio(1, 256)>(), pound> {};
|
||||
|
||||
struct ounce : named_scaled_unit<ounce, "oz", as_magnitude<ratio(1, 16)>(), pound> {};
|
||||
struct ounce : named_scaled_unit<ounce, "oz", mag<ratio(1, 16)>(), pound> {};
|
||||
|
||||
struct stone : named_scaled_unit<stone, "st", as_magnitude<14>(), pound> {};
|
||||
struct stone : named_scaled_unit<stone, "st", mag<14>(), pound> {};
|
||||
|
||||
struct quarter : named_scaled_unit<quarter, "qr", as_magnitude<28>(), pound> {};
|
||||
struct quarter : named_scaled_unit<quarter, "qr", mag<28>(), pound> {};
|
||||
|
||||
struct hundredweight : named_scaled_unit<hundredweight, "cwt", as_magnitude<112>(), pound> {};
|
||||
struct hundredweight : named_scaled_unit<hundredweight, "cwt", mag<112>(), pound> {};
|
||||
|
||||
struct short_ton : named_scaled_unit<short_ton, "ton (short)", as_magnitude<2'000>(), pound> {};
|
||||
struct short_ton : named_scaled_unit<short_ton, "ton (short)", mag<2'000>(), pound> {};
|
||||
|
||||
struct long_ton : named_scaled_unit<long_ton, "ton (long)", as_magnitude<2'240>(), pound> {};
|
||||
struct long_ton : named_scaled_unit<long_ton, "ton (long)", mag<2'240>(), pound> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct dim_power : isq::dim_power<dim_power, foot_poundal_per_second, dim_length
|
||||
struct foot_pound_force_per_second :
|
||||
derived_scaled_unit<foot_pound_force_per_second, dim_power, foot, pound_force, second> {};
|
||||
|
||||
struct horse_power : named_scaled_unit<horse_power, "hp", as_magnitude<550>(), foot_pound_force_per_second> {};
|
||||
struct horse_power : named_scaled_unit<horse_power, "hp", mag<550>(), foot_pound_force_per_second> {};
|
||||
|
||||
template<UnitOf<dim_power> U, Representation Rep = double>
|
||||
using power = quantity<dim_power, U, Rep>;
|
||||
|
||||
@@ -44,11 +44,10 @@ template<UnitOf<dim_pressure> U, Representation Rep = double>
|
||||
using pressure = quantity<dim_pressure, U, Rep>;
|
||||
|
||||
struct pound_force_per_foot_sq :
|
||||
named_scaled_unit<pound_force_per_foot_sq, "lbf ft2", as_magnitude<ratio(32'174'049, 1'000'000)>(),
|
||||
poundal_per_foot_sq> {};
|
||||
named_scaled_unit<pound_force_per_foot_sq, "lbf ft2", mag<ratio(32'174'049, 1'000'000)>(), poundal_per_foot_sq> {};
|
||||
|
||||
struct pound_force_per_inch_sq :
|
||||
named_scaled_unit<pound_force_per_inch_sq, "psi", as_magnitude<ratio(1, 144)>(), pound_force_per_foot_sq> {};
|
||||
named_scaled_unit<pound_force_per_inch_sq, "psi", mag<ratio(1, 144)>(), pound_force_per_foot_sq> {};
|
||||
|
||||
struct kilopound_force_per_inch_sq : prefixed_unit<kilopound_force_per_inch_sq, si::kilo, pound_force_per_inch_sq> {};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace units::isq::si::hep {
|
||||
|
||||
struct eV_per_c2 :
|
||||
named_scaled_unit<eV_per_c2, basic_symbol_text{"eV/c²", "eV/c^2"},
|
||||
as_magnitude<ratio(17'826'619'216'279, 1'000'000'000'000)>() * mag_power<10, -35>(), kilogram> {};
|
||||
mag<ratio(17'826'619'216'279, 1'000'000'000'000)>() * mag_power<10, -35>(), kilogram> {};
|
||||
struct feV_per_c2 : prefixed_unit<feV_per_c2, femto, eV_per_c2> {};
|
||||
struct peV_per_c2 : prefixed_unit<peV_per_c2, pico, eV_per_c2> {};
|
||||
struct neV_per_c2 : prefixed_unit<neV_per_c2, nano, eV_per_c2> {};
|
||||
@@ -60,14 +60,14 @@ struct PeV_per_c2 : prefixed_unit<PeV_per_c2, peta, eV_per_c2> {};
|
||||
struct EeV_per_c2 : prefixed_unit<EeV_per_c2, exa, eV_per_c2> {};
|
||||
struct YeV_per_c2 : prefixed_unit<YeV_per_c2, yotta, eV_per_c2> {};
|
||||
struct electron_mass :
|
||||
named_scaled_unit<eV_per_c2, "m_e",
|
||||
as_magnitude<ratio(9'109'383'701'528, 1'000'000'000'000)>() * mag_power<10, -31>(), kilogram> {};
|
||||
named_scaled_unit<eV_per_c2, "m_e", mag<ratio(9'109'383'701'528, 1'000'000'000'000)>() * mag_power<10, -31>(),
|
||||
kilogram> {};
|
||||
struct proton_mass :
|
||||
named_scaled_unit<eV_per_c2, "m_p",
|
||||
as_magnitude<ratio(1'672'621'923'695, 1'000'000'000'000)>() * mag_power<10, -27>(), kilogram> {};
|
||||
named_scaled_unit<eV_per_c2, "m_p", mag<ratio(1'672'621'923'695, 1'000'000'000'000)>() * mag_power<10, -27>(),
|
||||
kilogram> {};
|
||||
struct neutron_mass :
|
||||
named_scaled_unit<eV_per_c2, "m_n",
|
||||
as_magnitude<ratio(1'674'927'498'049, 1'000'000'000'000)>() * mag_power<10, -27>(), kilogram> {};
|
||||
named_scaled_unit<eV_per_c2, "m_n", mag<ratio(1'674'927'498'049, 1'000'000'000'000)>() * mag_power<10, -27>(),
|
||||
kilogram> {};
|
||||
|
||||
struct dim_mass : isq::dim_mass<eV_per_c2> {};
|
||||
|
||||
|
||||
@@ -41,8 +41,7 @@ namespace units::isq::si::hep {
|
||||
struct kilogram_metre_per_second : derived_unit<kilogram_metre_per_second> {};
|
||||
|
||||
struct eV_per_c :
|
||||
named_scaled_unit<eV_per_c, "eV/c",
|
||||
as_magnitude<ratio(5'344'285'992'678, 1'000'000'000'000)>() * mag_power<10, -35>(),
|
||||
named_scaled_unit<eV_per_c, "eV/c", mag<ratio(5'344'285'992'678, 1'000'000'000'000)>() * mag_power<10, -35>(),
|
||||
kilogram_metre_per_second> {};
|
||||
struct feV_per_c : prefixed_unit<feV_per_c, femto, eV_per_c> {};
|
||||
struct peV_per_c : prefixed_unit<peV_per_c, pico, eV_per_c> {};
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
namespace units::isq::si::iau {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Light-year
|
||||
struct light_year : named_scaled_unit<light_year, "ly", as_magnitude<9460730472580800>(), si::metre> {};
|
||||
struct light_year : named_scaled_unit<light_year, "ly", mag<9460730472580800>(), si::metre> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Parsec
|
||||
struct parsec : named_scaled_unit<parsec, "pc", as_magnitude<30'856'775'814'913'673>(), si::metre> {};
|
||||
struct parsec : named_scaled_unit<parsec, "pc", mag<30'856'775'814'913'673>(), si::metre> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Angstrom
|
||||
struct angstrom : named_scaled_unit<angstrom, "angstrom", mag_power<10, -10>(), si::metre> {};
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
namespace units::isq::si::imperial {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Chain_(unit)
|
||||
struct chain : named_scaled_unit<chain, "ch", as_magnitude<22>(), si::international::yard> {};
|
||||
struct chain : named_scaled_unit<chain, "ch", mag<22>(), si::international::yard> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Rod_(unit)
|
||||
struct rod : named_scaled_unit<rod, "rd", as_magnitude<ratio(1, 4)>(), chain> {};
|
||||
struct rod : named_scaled_unit<rod, "rd", mag<ratio(1, 4)>(), chain> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -37,30 +37,30 @@ namespace units::isq::si::international {
|
||||
|
||||
// si::international yard
|
||||
// https://en.wikipedia.org/wiki/International_yard_and_pound
|
||||
struct yard : named_scaled_unit<yard, "yd", as_magnitude<ratio{9'144, 10'000}>(), si::metre> {};
|
||||
struct yard : named_scaled_unit<yard, "yd", mag<ratio{9'144, 10'000}>(), si::metre> {};
|
||||
|
||||
// si::international foot
|
||||
// https://en.wikipedia.org/wiki/Foot_(unit)#International_foot
|
||||
struct foot : named_scaled_unit<foot, "ft", as_magnitude<ratio(1, 3)>(), yard> {};
|
||||
struct foot : named_scaled_unit<foot, "ft", mag<ratio(1, 3)>(), yard> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Fathom#International_fathom
|
||||
struct fathom : named_scaled_unit<fathom, "fathom", as_magnitude<2>(), yard> {};
|
||||
struct fathom : named_scaled_unit<fathom, "fathom", mag<2>(), yard> {};
|
||||
|
||||
// si::international inch
|
||||
// https://en.wikipedia.org/wiki/Inch#Equivalences
|
||||
struct inch : named_scaled_unit<inch, "in", as_magnitude<ratio(1, 36)>(), yard> {};
|
||||
struct inch : named_scaled_unit<inch, "in", mag<ratio(1, 36)>(), yard> {};
|
||||
|
||||
// intrnational mile
|
||||
// https://en.wikipedia.org/wiki/Mile#International_mile
|
||||
struct mile : named_scaled_unit<mile, "mi", as_magnitude<ratio(25'146, 15'625)>(), si::kilometre> {};
|
||||
struct mile : named_scaled_unit<mile, "mi", mag<ratio(25'146, 15'625)>(), si::kilometre> {};
|
||||
|
||||
// si::international nautical mile
|
||||
// https://en.wikipedia.org/wiki/Nautical_mile
|
||||
struct nautical_mile : named_scaled_unit<nautical_mile, "mi(naut)", as_magnitude<1852>(), si::metre> {};
|
||||
struct nautical_mile : named_scaled_unit<nautical_mile, "mi(naut)", mag<1852>(), si::metre> {};
|
||||
|
||||
// thou
|
||||
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||
struct thou : named_scaled_unit<thou, "thou", as_magnitude<ratio(1, 1000)>(), inch> {};
|
||||
struct thou : named_scaled_unit<thou, "thou", mag<ratio(1, 1000)>(), inch> {};
|
||||
|
||||
// mil - different name for thou
|
||||
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||
|
||||
@@ -37,17 +37,13 @@ namespace units::isq::si::typographic {
|
||||
|
||||
// TODO Conflicts with (https://en.wikipedia.org/wiki/Pica_(typography)), verify correctness of below conversion factors
|
||||
// and provide hyperlinks to definitions
|
||||
struct pica_comp :
|
||||
named_scaled_unit<pica_comp, "pica(comp)", as_magnitude<4'233'333>() * mag_power<10, -9>(), si::metre> {};
|
||||
struct pica_comp : named_scaled_unit<pica_comp, "pica(comp)", mag<4'233'333>() * mag_power<10, -9>(), si::metre> {};
|
||||
struct pica_prn :
|
||||
named_scaled_unit<pica_prn, "pica(prn)", as_magnitude<ratio(2108759, 500000)>() * mag_power<10, -3>(), si::metre> {
|
||||
};
|
||||
named_scaled_unit<pica_prn, "pica(prn)", mag<ratio(2108759, 500000)>() * mag_power<10, -3>(), si::metre> {};
|
||||
struct point_comp :
|
||||
named_scaled_unit<point_comp, "point(comp)", as_magnitude<ratio(1763889, 500000)>() * mag_power<10, -4>(),
|
||||
si::metre> {};
|
||||
named_scaled_unit<point_comp, "point(comp)", mag<ratio(1763889, 500000)>() * mag_power<10, -4>(), si::metre> {};
|
||||
struct point_prn :
|
||||
named_scaled_unit<point_prn, "point(prn)", as_magnitude<ratio(1757299, 500000)>() * mag_power<10, -4>(),
|
||||
si::metre> {};
|
||||
named_scaled_unit<point_prn, "point(prn)", mag<ratio(1757299, 500000)>() * mag_power<10, -4>(), si::metre> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ namespace units::isq::si::uscs {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Foot_(unit)#US_survey_foot
|
||||
// https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct foot : named_scaled_unit<foot, "ft(us)", as_magnitude<ratio(1'200, 3'937)>(), si::metre> {};
|
||||
struct foot : named_scaled_unit<foot, "ft(us)", mag<ratio(1'200, 3'937)>(), si::metre> {};
|
||||
|
||||
// https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct fathom : named_scaled_unit<fathom, "fathom(us)", as_magnitude<6>(), foot> {};
|
||||
struct fathom : named_scaled_unit<fathom, "fathom(us)", mag<6>(), foot> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Mile#U.S._survey_mile
|
||||
// https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct mile : named_scaled_unit<mile, "mi(us)", as_magnitude<5280>(), foot> {};
|
||||
struct mile : named_scaled_unit<mile, "mi(us)", mag<5280>(), foot> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ struct exakatal : prefixed_unit<exakatal, exa, katal> {};
|
||||
struct zettakatal : prefixed_unit<zettakatal, zetta, katal> {};
|
||||
struct yottakatal : prefixed_unit<yottakatal, yotta, katal> {};
|
||||
|
||||
struct enzyme_unit : named_scaled_unit<enzyme_unit, "U", as_magnitude<ratio(1, 60)>() * mag_power<10, -6>(), katal> {};
|
||||
struct enzyme_unit : named_scaled_unit<enzyme_unit, "U", mag<ratio(1, 60)>() * mag_power<10, -6>(), katal> {};
|
||||
|
||||
struct dim_catalytic_activity :
|
||||
isq::dim_catalytic_activity<dim_catalytic_activity, katal, dim_time, dim_amount_of_substance> {};
|
||||
|
||||
@@ -56,8 +56,7 @@ struct yottajoule : prefixed_unit<yottajoule, yotta, joule> {};
|
||||
// N.B. electron charge (and eV) is an exact constant:
|
||||
// https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147
|
||||
struct electronvolt :
|
||||
named_scaled_unit<electronvolt, "eV", as_magnitude<ratio(1'602'176'634, 1'000'000'000)>() * mag_power<10, -19>(),
|
||||
joule> {};
|
||||
named_scaled_unit<electronvolt, "eV", mag<ratio(1'602'176'634, 1'000'000'000)>() * mag_power<10, -19>(), joule> {};
|
||||
struct gigaelectronvolt : prefixed_unit<gigaelectronvolt, giga, electronvolt> {};
|
||||
|
||||
struct dim_energy : isq::dim_energy<dim_energy, joule, dim_force, dim_length> {};
|
||||
|
||||
@@ -56,7 +56,7 @@ struct exametre : prefixed_unit<exametre, exa, metre> {};
|
||||
struct zettametre : prefixed_unit<zettametre, zetta, metre> {};
|
||||
struct yottametre : prefixed_unit<yottametre, yotta, metre> {};
|
||||
|
||||
struct astronomical_unit : named_scaled_unit<astronomical_unit, "au", as_magnitude<149'597'870'700>(), metre> {};
|
||||
struct astronomical_unit : named_scaled_unit<astronomical_unit, "au", mag<149'597'870'700>(), metre> {};
|
||||
|
||||
struct dim_length : isq::dim_length<metre> {};
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace units::isq::si {
|
||||
|
||||
// TODO Is this correct? Should we account for steradian here? How?
|
||||
|
||||
struct lumen : named_scaled_unit<lumen, "lm", as_magnitude<ratio(1, 683)>(), watt> {};
|
||||
struct lumen : named_scaled_unit<lumen, "lm", mag<ratio(1, 683)>(), watt> {};
|
||||
|
||||
using dim_luminous_flux = dim_power;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ struct exatesla : prefixed_unit<exatesla, exa, tesla> {};
|
||||
struct zettatesla : prefixed_unit<zettatesla, zetta, tesla> {};
|
||||
struct yottatesla : prefixed_unit<yottatesla, yotta, tesla> {};
|
||||
|
||||
struct gauss : named_scaled_unit<gauss, "G", as_magnitude<ratio(1, 10'000)>(), tesla> {};
|
||||
struct gauss : named_scaled_unit<gauss, "G", mag<ratio(1, 10'000)>(), tesla> {};
|
||||
|
||||
struct dim_magnetic_induction :
|
||||
isq::dim_magnetic_induction<dim_magnetic_induction, tesla, dim_voltage, dim_time, dim_length> {};
|
||||
|
||||
@@ -79,9 +79,8 @@ struct zettatonne : prefixed_unit<zettatonne, zetta, tonne> {};
|
||||
struct yottatonne : prefixed_unit<yottatonne, yotta, tonne> {};
|
||||
|
||||
struct dalton :
|
||||
named_scaled_unit<dalton, "Da",
|
||||
as_magnitude<ratio(16'605'390'666'050, 10'000'000'000'000)>() * mag_power<10, -27>(), kilogram> {
|
||||
};
|
||||
named_scaled_unit<dalton, "Da", mag<ratio(16'605'390'666'050, 10'000'000'000'000)>() * mag_power<10, -27>(),
|
||||
kilogram> {};
|
||||
|
||||
struct dim_mass : isq::dim_mass<kilogram> {};
|
||||
|
||||
|
||||
@@ -27,26 +27,26 @@
|
||||
namespace units::isq::si {
|
||||
|
||||
// clang-format off
|
||||
struct yocto : prefix<yocto, "y", pow<-24>(as_magnitude<10>())> {};
|
||||
struct zepto : prefix<zepto, "z", pow<-21>(as_magnitude<10>())> {};
|
||||
struct atto : prefix<atto, "a", pow<-18>(as_magnitude<10>())> {};
|
||||
struct femto : prefix<femto, "f", pow<-15>(as_magnitude<10>())> {};
|
||||
struct pico : prefix<pico, "p", pow<-12>(as_magnitude<10>())> {};
|
||||
struct nano : prefix<nano, "n", pow<-9>(as_magnitude<10>())> {};
|
||||
struct micro : prefix<micro, basic_symbol_text{"\u00b5", "u"}, pow<-6>(as_magnitude<10>())> {};
|
||||
struct milli : prefix<milli, "m", pow<-3>(as_magnitude<10>())> {};
|
||||
struct centi : prefix<centi, "c", pow<-2>(as_magnitude<10>())> {};
|
||||
struct deci : prefix<deci, "d", pow<-1>(as_magnitude<10>())> {};
|
||||
struct deca : prefix<deca, "da", pow<1>(as_magnitude<10>())> {};
|
||||
struct hecto : prefix<hecto, "h", pow<2>(as_magnitude<10>())> {};
|
||||
struct kilo : prefix<kilo, "k", pow<3>(as_magnitude<10>())> {};
|
||||
struct mega : prefix<mega, "M", pow<6>(as_magnitude<10>())> {};
|
||||
struct giga : prefix<giga, "G", pow<9>(as_magnitude<10>())> {};
|
||||
struct tera : prefix<tera, "T", pow<12>(as_magnitude<10>())> {};
|
||||
struct peta : prefix<peta, "P", pow<15>(as_magnitude<10>())> {};
|
||||
struct exa : prefix<exa, "E", pow<18>(as_magnitude<10>())> {};
|
||||
struct zetta : prefix<zetta, "Z", pow<21>(as_magnitude<10>())> {};
|
||||
struct yotta : prefix<yotta, "Y", pow<24>(as_magnitude<10>())> {};
|
||||
struct yocto : prefix<yocto, "y", pow<-24>(mag<10>())> {};
|
||||
struct zepto : prefix<zepto, "z", pow<-21>(mag<10>())> {};
|
||||
struct atto : prefix<atto, "a", pow<-18>(mag<10>())> {};
|
||||
struct femto : prefix<femto, "f", pow<-15>(mag<10>())> {};
|
||||
struct pico : prefix<pico, "p", pow<-12>(mag<10>())> {};
|
||||
struct nano : prefix<nano, "n", pow<-9>(mag<10>())> {};
|
||||
struct micro : prefix<micro, basic_symbol_text{"\u00b5", "u"}, pow<-6>(mag<10>())> {};
|
||||
struct milli : prefix<milli, "m", pow<-3>(mag<10>())> {};
|
||||
struct centi : prefix<centi, "c", pow<-2>(mag<10>())> {};
|
||||
struct deci : prefix<deci, "d", pow<-1>(mag<10>())> {};
|
||||
struct deca : prefix<deca, "da", pow<1>(mag<10>())> {};
|
||||
struct hecto : prefix<hecto, "h", pow<2>(mag<10>())> {};
|
||||
struct kilo : prefix<kilo, "k", pow<3>(mag<10>())> {};
|
||||
struct mega : prefix<mega, "M", pow<6>(mag<10>())> {};
|
||||
struct giga : prefix<giga, "G", pow<9>(mag<10>())> {};
|
||||
struct tera : prefix<tera, "T", pow<12>(mag<10>())> {};
|
||||
struct peta : prefix<peta, "P", pow<15>(mag<10>())> {};
|
||||
struct exa : prefix<exa, "E", pow<18>(mag<10>())> {};
|
||||
struct zetta : prefix<zetta, "Z", pow<21>(mag<10>())> {};
|
||||
struct yotta : prefix<yotta, "Y", pow<24>(mag<10>())> {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::isq::si
|
||||
|
||||
@@ -43,9 +43,9 @@ struct picosecond : prefixed_unit<picosecond, pico, second> {};
|
||||
struct nanosecond : prefixed_unit<nanosecond, nano, second> {};
|
||||
struct microsecond : prefixed_unit<microsecond, micro, second> {};
|
||||
struct millisecond : prefixed_unit<millisecond, milli, second> {};
|
||||
struct minute : named_scaled_unit<minute, "min", as_magnitude<60>(), second> {};
|
||||
struct hour : named_scaled_unit<hour, "h", as_magnitude<60>(), minute> {};
|
||||
struct day : named_scaled_unit<day, "d", as_magnitude<24>(), hour> {};
|
||||
struct minute : named_scaled_unit<minute, "min", mag<60>(), second> {};
|
||||
struct hour : named_scaled_unit<hour, "h", mag<60>(), minute> {};
|
||||
struct day : named_scaled_unit<day, "d", mag<24>(), hour> {};
|
||||
|
||||
struct dim_time : isq::dim_time<second> {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user