Skip to content

Commit

Permalink
refactor: 💥 ratio hidden as an implementation detail behind `mag_ra…
Browse files Browse the repository at this point in the history
…tio`
  • Loading branch information
mpusz committed Apr 19, 2024
1 parent ae1003b commit f90a218
Show file tree
Hide file tree
Showing 24 changed files with 126 additions and 129 deletions.
8 changes: 4 additions & 4 deletions docs/users_guide/framework_basics/dimensionless_quantities.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ units of _length_:
```cpp
inline constexpr struct hubble_constant :
named_unit<{u8"H₀", "H_0"}, mag<ratio{701, 10}> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant;
named_unit<{u8"H₀", "H_0"}, mag_ratio<701, 10> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant;
```


Expand Down Expand Up @@ -158,9 +158,9 @@ Besides the unit `one`, there are a few other scaled units predefined in the lib
with dimensionless quantities:

```cpp
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
inline constexpr struct per_mille : named_unit<{u8"‰", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
inline constexpr struct parts_per_million : named_unit<"ppm", mag<ratio(1, 1'000'000)> * one> {} parts_per_million;
inline constexpr struct percent : named_unit<"%", mag_ratio<1, 100> * one> {} percent;
inline constexpr struct per_mille : named_unit<{u8"‰", "%o"}, mag_ratio<1, 1000> * one> {} per_mille;
inline constexpr struct parts_per_million : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million;
inline constexpr auto ppm = parts_per_million;
```
Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/framework_basics/systems_of_units.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ electronvolt:
```cpp
inline constexpr struct minute : named_unit<"min", mag<60> * si::second> {} minute;
inline constexpr struct hour : named_unit<"h", mag<60> * minute> {} hour;
inline constexpr struct electronvolt : named_unit<"eV", mag<ratio{1'602'176'634, 1'000'000'000}> * mag_power<10, -19> * si::joule> {} electronvolt;
inline constexpr struct electronvolt : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt;
```

Also, units of other [systems of units](../../appendix/glossary.md#system-of-units) are often defined
in terms of scaled versions of the SI units. For example, the international yard is defined as:

```cpp
inline constexpr struct yard : named_unit<"yd", mag<ratio{9'144, 10'000}> * si::metre> {} yard;
inline constexpr struct yard : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
```
For some units, a magnitude might also be irrational. The best example here is a `degree` which
Expand Down
8 changes: 4 additions & 4 deletions docs/users_guide/framework_basics/text_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ and units of derived quantities.
```cpp
inline constexpr struct hyperfine_structure_transition_frequency_of_cs : named_unit<{u8"Δν_Cs", "dv_Cs"}, mag<9'192'631'770> * hertz> {} hyperfine_structure_transition_frequency_of_cs;
inline constexpr struct speed_of_light_in_vacuum : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
inline constexpr struct planck_constant : named_unit<"h", mag<ratio{662'607'015, 100'000'000}> * mag_power<10, -34> * joule * second> {} planck_constant;
inline constexpr struct elementary_charge : named_unit<"e", mag<ratio{1'602'176'634, 1'000'000'000}> * mag_power<10, -19> * coulomb> {} elementary_charge;
inline constexpr struct boltzmann_constant : named_unit<"k", mag<ratio{1'380'649, 1'000'000}> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant;
inline constexpr struct avogadro_constant : named_unit<"N_A", mag<ratio{602'214'076, 100'000'000}> * mag_power<10, 23> / mole> {} avogadro_constant;
inline constexpr struct planck_constant : named_unit<"h", mag_ratio<662'607'015, 100'000'000> * mag_power<10, -34> * joule * second> {} planck_constant;
inline constexpr struct elementary_charge : named_unit<"e", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * coulomb> {} elementary_charge;
inline constexpr struct boltzmann_constant : named_unit<"k", mag_ratio<1'380'649, 1'000'000> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant;
inline constexpr struct avogadro_constant : named_unit<"N_A", mag_ratio<602'214'076, 100'000'000> * mag_power<10, 23> / mole> {} avogadro_constant;
inline constexpr struct luminous_efficacy : named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
```

Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/framework_basics/the_affine_space.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ inline constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_de
namespace usc {
inline constexpr struct zeroth_degree_Fahrenheit :
relative_point_origin<si::zeroth_degree_Celsius - 32 * (mag<ratio{5, 9}> * si::degree_Celsius)> {} zeroth_degree_Fahrenheit;
relative_point_origin<si::zeroth_degree_Celsius - 32 * (mag_ratio<5, 9> * si::degree_Celsius)> {} zeroth_degree_Fahrenheit;
}
```
Expand Down Expand Up @@ -436,7 +436,7 @@ inline constexpr struct degree_Celsius :
namespace usc {

inline constexpr struct degree_Fahrenheit :
named_unit<{u8"°F", "`F"}, mag<ratio{5, 9}> * si::degree_Celsius,
named_unit<{u8"°F", "`F"}, mag_ratio<5, 9> * si::degree_Celsius,
zeroth_degree_Fahrenheit> {} degree_Fahrenheit;

}
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/mp-units/bits/expression_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ template<typename F, int Num, int... Den>
requires(detail::valid_ratio<Num, Den...> && detail::positive_ratio<Num, Den...> && !detail::ratio_one<Num, Den...>)
struct power {
using factor = F;
static constexpr ratio exponent{Num, Den...};
static constexpr detail::ratio exponent{Num, Den...};
};

namespace detail {
Expand Down
30 changes: 15 additions & 15 deletions src/core/include/mp-units/bits/magnitude.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ template<PowerVBase auto V, int Num, int... Den>
requires(detail::valid_ratio<Num, Den...> && !detail::ratio_one<Num, Den...>)
struct power_v {
static constexpr auto base = V;
static constexpr ratio exponent{Num, Den...};
static constexpr detail::ratio exponent{Num, Den...};
};

namespace detail {
Expand Down Expand Up @@ -565,7 +565,8 @@ template<std::intmax_t Num, std::intmax_t Den = 1, auto... Ms>
if constexpr (Num == 0) {
return magnitude<>{};
} else {
return magnitude<detail::power_v_or_T<detail::get_base(Ms), detail::get_exponent(Ms) * ratio{Num, Den}>()...>{};
return magnitude<
detail::power_v_or_T<detail::get_base(Ms), detail::get_exponent(Ms) * detail::ratio{Num, Den}>()...>{};
}
}

Expand Down Expand Up @@ -675,8 +676,6 @@ template<auto M>
}
}

} // namespace detail

template<auto... Ms>
[[nodiscard]] consteval auto numerator(magnitude<Ms...>)
{
Expand All @@ -685,8 +684,8 @@ template<auto... Ms>

[[nodiscard]] consteval auto denominator(Magnitude auto m) { return numerator(pow<-1>(m)); }

// Implementation of conversion to ratio goes here, because it needs `numerator()` and `denominator()`.
constexpr ratio as_ratio(Magnitude auto m)
// TODO This probably should not be exported but is used in chrono.h
MP_UNITS_EXPORT constexpr ratio as_ratio(Magnitude auto m)
requires(is_rational(decltype(m){}))
{
return ratio{
Expand All @@ -695,7 +694,6 @@ constexpr ratio as_ratio(Magnitude auto m)
};
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Common Magnitude.
//
Expand All @@ -714,8 +712,6 @@ constexpr ratio as_ratio(Magnitude auto m)
// Thus, we make the _simplest_ choice which reproduces the correct convention in the rational case: namely, taking the
// minimum power for each base (where absent bases implicitly have a power of 0).

namespace detail {

template<auto M>
[[nodiscard]] consteval auto remove_positive_power(magnitude<M> m)
{
Expand Down Expand Up @@ -830,16 +826,20 @@ inline constexpr auto prime_factorization_v = prime_factorization<N>::value;
* This will be the main way end users create Magnitudes. They should rarely (if ever) create a magnitude<...> by
* manually adding base powers.
*/
MP_UNITS_EXPORT template<ratio R>
requires detail::gt_zero<R.num>
inline constexpr Magnitude auto mag = detail::prime_factorization_v<R.num> / detail::prime_factorization_v<R.den>;
MP_UNITS_EXPORT template<std::intmax_t V>
requires detail::gt_zero<V>
inline constexpr Magnitude auto mag = detail::prime_factorization_v<V>;

MP_UNITS_EXPORT template<std::intmax_t N, std::intmax_t D>
requires detail::gt_zero<N>
inline constexpr Magnitude auto mag_ratio = detail::prime_factorization_v<N> / detail::prime_factorization_v<D>;

/**
* @brief Create a Magnitude which is some rational number raised to a rational power.
*/
MP_UNITS_EXPORT template<ratio Base, ratio Pow>
requires detail::gt_zero<Base.num>
inline constexpr Magnitude auto mag_power = pow<Pow.num, Pow.den>(mag<Base>);
MP_UNITS_EXPORT template<std::intmax_t Base, std::intmax_t Pow>
requires detail::gt_zero<Base>
inline constexpr Magnitude auto mag_power = pow<Pow>(mag<Base>);

namespace detail {

Expand Down
9 changes: 3 additions & 6 deletions src/core/include/mp-units/bits/ratio.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#include <numeric>
#endif

namespace mp_units {

namespace detail {
namespace mp_units::detail {

template<typename T>
[[nodiscard]] MP_UNITS_CONSTEVAL T abs(T v) noexcept
Expand All @@ -59,14 +57,13 @@ template<typename T>
return lhs * rhs;
}

} // namespace detail

/**
* @brief Provides compile-time rational arithmetic support.
*
* This class is really similar to @c std::ratio. An important difference is the fact that the objects of that class
* are used as class NTTPs rather then a type template parameter kind.
*/
// TODO This probably should not be exported but is used in chrono.h
MP_UNITS_EXPORT struct ratio {
std::intmax_t num;
std::intmax_t den;
Expand Down Expand Up @@ -123,4 +120,4 @@ MP_UNITS_EXPORT struct ratio {
return ratio{num / gcd, den / gcd};
}

} // namespace mp_units
} // namespace mp_units::detail
2 changes: 1 addition & 1 deletion src/core/include/mp-units/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, auto R, typename Rep>
{
if constexpr (Num == 0) {
return quantity<pow<Num, Den>(R), Rep>::one();
} else if constexpr (ratio{Num, Den} == 1) {
} else if constexpr (Num == Den) {
return q;
} else {
using std::pow;
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/mp-units/quantity_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, QuantitySpec Q>
// all are dimensionless quantities :-(
if constexpr (Num == 0 || Q{} == dimensionless)
return dimensionless;
else if constexpr (ratio{Num, Den} == 1)
else if constexpr (detail::ratio{Num, Den} == 1)
return q;
else if constexpr (detail::IntermediateDerivedQuantitySpec<Q>)
return detail::clone_kind_of<Q{}>(
Expand Down
8 changes: 4 additions & 4 deletions src/core/include/mp-units/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
{
if constexpr (Num == 0 || is_same_v<U, struct one>)
return one;
else if constexpr (ratio{Num, Den} == 1)
else if constexpr (detail::ratio{Num, Den} == 1)
return u;
else if constexpr (detail::is_specialization_of_scaled_unit<U>)
return scaled_unit<pow<Num, Den>(U::mag), std::remove_const_t<decltype(pow<Num, Den>(U::reference_unit))>>{};
Expand Down Expand Up @@ -617,9 +617,9 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>

// common dimensionless units
// clang-format off
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
inline constexpr struct per_mille : named_unit<symbol_text{u8"", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
inline constexpr struct parts_per_million : named_unit<"ppm", mag<ratio(1, 1'000'000)> * one> {} parts_per_million;
inline constexpr struct percent : named_unit<"%", mag_ratio<1, 100> * one> {} percent;
inline constexpr struct per_mille : named_unit<symbol_text{u8"", "%o"}, mag_ratio<1, 1000> * one> {} per_mille;
inline constexpr struct parts_per_million : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million;
inline constexpr auto ppm = parts_per_million;
// clang-format on

Expand Down
4 changes: 2 additions & 2 deletions src/systems/include/mp-units/systems/angular/units.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ QUANTITY_SPEC(solid_angle, pow<2>(angle));

inline constexpr struct radian : named_unit<"rad", kind_of<angle>> {} radian;
inline constexpr struct revolution : named_unit<"rev", mag<2> * mag_pi * radian> {} revolution;
inline constexpr struct degree : named_unit<symbol_text{u8"°", "deg"}, mag<ratio{1, 360}> * revolution> {} degree;
inline constexpr struct gradian : named_unit<symbol_text{u8"", "grad"}, mag<ratio{1, 400}> * revolution> {} gradian;
inline constexpr struct degree : named_unit<symbol_text{u8"°", "deg"}, mag_ratio<1, 360> * revolution> {} degree;
inline constexpr struct gradian : named_unit<symbol_text{u8"", "grad"}, mag_ratio<1, 400> * revolution> {} gradian;
inline constexpr struct steradian : named_unit<"sr", square(radian)> {} steradian;
// clang-format on

Expand Down
6 changes: 3 additions & 3 deletions src/systems/include/mp-units/systems/hep/hep.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ using si::electronvolt;
inline constexpr struct barn : named_unit<"b", mag_power<10, -28> * square(si::metre)> {} barn;

// mass
inline constexpr struct electron_mass : named_unit<"m_e", mag<ratio{9'109'383'701'528, 1'000'000'000'000}> * mag_power<10, -31> * si::kilogram> {} electron_mass;
inline constexpr struct proton_mass : named_unit<"m_p", mag<ratio{1'672'621'923'695, 1'000'000'000'000}> * mag_power<10, -27> * si::kilogram> {} proton_mass;
inline constexpr struct neutron_mass : named_unit<"m_n", mag<ratio{1'674'927'498'049, 1'000'000'000'000}> * mag_power<10, -27> * si::kilogram> {} neutron_mass;
inline constexpr struct electron_mass : named_unit<"m_e", mag_ratio<9'109'383'701'528, 1'000'000'000'000> * mag_power<10, -31> * si::kilogram> {} electron_mass;
inline constexpr struct proton_mass : named_unit<"m_p", mag_ratio<1'672'621'923'695, 1'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} proton_mass;
inline constexpr struct neutron_mass : named_unit<"m_n", mag_ratio<1'674'927'498'049, 1'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} neutron_mass;

// speed
inline constexpr struct speed_of_light : decltype(si::si2019::speed_of_light_in_vacuum) {} speed_of_light;
Expand Down
16 changes: 8 additions & 8 deletions src/systems/include/mp-units/systems/iau/iau.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ namespace mp_units::iau {
// clang-format off
// time
inline constexpr struct day : named_unit<"D", si::day> {} day;
inline constexpr struct Julian_year : named_unit<"a", mag<ratio{365'25, 100}> * day> {} Julian_year;
inline constexpr struct Julian_year : named_unit<"a", mag_ratio<365'25, 100> * day> {} Julian_year;

// mass
// https://en.wikipedia.org/wiki/Solar_mass
// TODO What is the official mass of sun (every source in the Internet provides a different value)
inline constexpr struct solar_mass : named_unit<symbol_text{u8"M_☉", "M_SUN"}, mag<ratio{198'847, 100'000}> * mag_power<10, 30> * si::kilogram> {} solar_mass;
inline constexpr struct Jupiter_mass : named_unit<"M_JUP", mag<ratio{1'898, 1'000}> * mag_power<10, 27> * si::kilogram> {} Jupiter_mass;
inline constexpr struct Earth_mass : named_unit<"M_EARTH", mag<ratio{59'742, 10'000}> * mag_power<10, 24> * si::kilogram> {} Earth_mass;
inline constexpr struct solar_mass : named_unit<symbol_text{u8"M_☉", "M_SUN"}, mag_ratio<198'847, 100'000> * mag_power<10, 30> * si::kilogram> {} solar_mass;
inline constexpr struct Jupiter_mass : named_unit<"M_JUP", mag_ratio<1'898, 1'000> * mag_power<10, 27> * si::kilogram> {} Jupiter_mass;
inline constexpr struct Earth_mass : named_unit<"M_EARTH", mag_ratio<59'742, 10'000> * mag_power<10, 24> * si::kilogram> {} Earth_mass;

// length
inline constexpr struct astronomical_unit : decltype(si::astronomical_unit) {} astronomical_unit;
Expand All @@ -57,24 +57,24 @@ inline constexpr struct lunar_distance : named_unit<"LD", mag<384'399> * si::kil
inline constexpr struct light_year : named_unit<"ly", mag<9'460'730'472'580'800> * si::metre> {} light_year;

// https://en.wikipedia.org/wiki/Parsec
inline constexpr struct parsec : named_unit<"pc", astronomical_unit / (mag<ratio{1, 60 * 60}> * si::degree)> {} parsec;
inline constexpr struct parsec : named_unit<"pc", astronomical_unit / (mag_ratio<1, 60 * 60> * si::degree)> {} parsec;

// https://en.wikipedia.org/wiki/Angstrom
inline constexpr struct angstrom : named_unit<symbol_text{u8"Å", "A"}, mag_power<10, -10> * si::metre> {} angstrom;

// selected constants
// https://en.wikipedia.org/wiki/Astronomical_constant
inline constexpr struct gaussian_gravitational_constant :
named_unit<"k", mag<ratio{1'720'209'895, 100'000'000'000}> * pow<3, 2>(astronomical_unit) / pow<1,2>(solar_mass) / day> {} gaussian_gravitational_constant;
named_unit<"k", mag_ratio<1'720'209'895, 100'000'000'000> * pow<3, 2>(astronomical_unit) / pow<1,2>(solar_mass) / day> {} gaussian_gravitational_constant;

inline constexpr struct speed_of_light :
named_unit<symbol_text{u8"c₀", "c_0"}, si::si2019::speed_of_light_in_vacuum> {} speed_of_light;

inline constexpr struct constant_of_gravitation :
named_unit<"G", mag<ratio{667'430, 100'000}> * mag_power<10, -11> * cubic(si::metre) / si::kilogram / square(si::second)> {} constant_of_gravitation;
named_unit<"G", mag_ratio<667'430, 100'000> * mag_power<10, -11> * cubic(si::metre) / si::kilogram / square(si::second)> {} constant_of_gravitation;

inline constexpr struct hubble_constant :
named_unit<symbol_text{u8"H₀", "H_0"}, mag<ratio{701, 10}> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant;
named_unit<symbol_text{u8"H₀", "H_0"}, mag_ratio<701, 10> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant;
// clang-format on

namespace unit_symbols {
Expand Down
22 changes: 11 additions & 11 deletions src/systems/include/mp-units/systems/imperial/imperial.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ using namespace international;

// clang-format off
// https://en.wikipedia.org/wiki/Imperial_units#Length
inline constexpr struct hand : named_unit<"hh", mag<ratio{1, 3}> * foot> {} hand;
inline constexpr struct barleycorn : named_unit<"Bc", mag<ratio(1, 3)> * inch> {} barleycorn;
inline constexpr struct thou : named_unit<"th", mag<ratio{1, 12'000}> * foot> {} thou;
inline constexpr struct hand : named_unit<"hh", mag_ratio<1, 3> * foot> {} hand;
inline constexpr struct barleycorn : named_unit<"Bc", mag_ratio<1, 3> * inch> {} barleycorn;
inline constexpr struct thou : named_unit<"th", mag_ratio<1, 12'000> * foot> {} thou;
inline constexpr struct chain : named_unit<"ch", mag<22> * yard> {} chain;
inline constexpr struct furlong : named_unit<"fur", mag<10> * chain> {} furlong;

// maritime units
inline constexpr struct cable : named_unit<"cb", mag<ratio{1, 10}> * nautical_mile> {} cable;
inline constexpr struct fathom : named_unit<"ftm", mag<ratio{1, 1000}> * nautical_mile> {} fathom;
inline constexpr struct cable : named_unit<"cb", mag_ratio<1, 10> * nautical_mile> {} cable;
inline constexpr struct fathom : named_unit<"ftm", mag_ratio<1, 1000> * nautical_mile> {} fathom;

// survey
inline constexpr struct link : named_unit<"li", mag<ratio{1, 100}> * chain> {} link;
inline constexpr struct link : named_unit<"li", mag_ratio<1, 100> * chain> {} link;
inline constexpr struct rod : named_unit<"rd", mag<25> * link> {} rod;

// https://en.wikipedia.org/wiki/Imperial_units#Area
Expand All @@ -56,11 +56,11 @@ inline constexpr struct rood : decltype(mag<40> * perch) {} rood;
inline constexpr struct acre : decltype(mag<4> * rood) {} acre;

// https://en.wikipedia.org/wiki/Imperial_units#Volume
inline constexpr struct gallon : named_unit<"gal", mag<ratio{454'609, 100'000}> * si::litre> {} gallon;
inline constexpr struct quart : named_unit<"qt", mag<ratio{1, 4}> * gallon> {} quart;
inline constexpr struct pint : named_unit<"pt", mag<ratio{1, 2}> * quart> {} pint;
inline constexpr struct gill : named_unit<"gi", mag<ratio{1, 4}> * pint> {} gill;
inline constexpr struct fluid_ounce : named_unit<"fl oz", mag<ratio{1, 5}> * gill> {} fluid_ounce;
inline constexpr struct gallon : named_unit<"gal", mag_ratio<454'609, 100'000> * si::litre> {} gallon;
inline constexpr struct quart : named_unit<"qt", mag_ratio<1, 4> * gallon> {} quart;
inline constexpr struct pint : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint;
inline constexpr struct gill : named_unit<"gi", mag_ratio<1, 4> * pint> {} gill;
inline constexpr struct fluid_ounce : named_unit<"fl oz", mag_ratio<1, 5> * gill> {} fluid_ounce;

// https://en.wikipedia.org/wiki/Avoirdupois_system#Post-Elizabethan_units
inline constexpr auto drachm = dram;
Expand Down
Loading

0 comments on commit f90a218

Please sign in to comment.