From 6a9dcb30def15d28b499c65c6dccca08a9be78ba Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Thu, 7 Jul 2022 19:00:38 +0000 Subject: [PATCH] Migrate explicit-`exp` inputs --- example/custom_systems.cpp | 2 +- .../si-hep/include/units/isq/si/hep/area.h | 2 +- .../si-hep/include/units/isq/si/hep/mass.h | 15 +++++++++++---- .../si-hep/include/units/isq/si/hep/momentum.h | 3 ++- .../si-iau/include/units/isq/si/iau/length.h | 2 +- .../include/units/isq/si/international/length.h | 2 +- .../include/units/isq/si/typographic/length.h | 13 +++++++++---- .../si/include/units/isq/si/catalytic_activity.h | 3 ++- src/systems/si/include/units/isq/si/energy.h | 3 ++- src/systems/si/include/units/isq/si/mass.h | 4 +++- test/unit_test/static/quantity_test.cpp | 7 +++---- test/unit_test/static/unit_test.cpp | 6 +++--- 12 files changed, 39 insertions(+), 23 deletions(-) diff --git a/example/custom_systems.cpp b/example/custom_systems.cpp index b2c3419d..4604be9e 100644 --- a/example/custom_systems.cpp +++ b/example/custom_systems.cpp @@ -54,7 +54,7 @@ using length = quantity; namespace fps { -struct foot : named_scaled_unit(), metre> {}; +struct foot : named_scaled_unit(), metre> {}; struct yard : named_scaled_unit(), foot> {}; struct dim_length : base_dimension<"L", foot> {}; diff --git a/src/systems/si-hep/include/units/isq/si/hep/area.h b/src/systems/si-hep/include/units/isq/si/hep/area.h index e08b59eb..658a12a8 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/area.h +++ b/src/systems/si-hep/include/units/isq/si/hep/area.h @@ -37,7 +37,7 @@ namespace units::isq::si::hep { // effective cross-sectional area according to EU council directive 80/181/EEC // https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:01980L0181-20090527#page=10 // https://www.fedlex.admin.ch/eli/cc/1994/3109_3109_3109/de -struct barn : named_scaled_unit(), square_metre> {}; +struct barn : named_scaled_unit(as_magnitude<10>()), square_metre> {}; struct yocto_barn : prefixed_unit {}; struct zepto_barn : prefixed_unit {}; struct atto_barn : prefixed_unit {}; diff --git a/src/systems/si-hep/include/units/isq/si/hep/mass.h b/src/systems/si-hep/include/units/isq/si/hep/mass.h index e4a895e0..754c2a61 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/mass.h +++ b/src/systems/si-hep/include/units/isq/si/hep/mass.h @@ -44,7 +44,8 @@ namespace units::isq::si::hep { struct eV_per_c2 : named_scaled_unit(), kilogram> {}; + as_magnitude() * pow<-35>(as_magnitude<10>()), + kilogram> {}; struct feV_per_c2 : prefixed_unit {}; struct peV_per_c2 : prefixed_unit {}; struct neV_per_c2 : prefixed_unit {}; @@ -60,11 +61,17 @@ struct PeV_per_c2 : prefixed_unit {}; struct EeV_per_c2 : prefixed_unit {}; struct YeV_per_c2 : prefixed_unit {}; struct electron_mass : - named_scaled_unit(), kilogram> {}; + named_scaled_unit() * pow<-31>(as_magnitude<10>()), + kilogram> {}; struct proton_mass : - named_scaled_unit(), kilogram> {}; + named_scaled_unit() * pow<-27>(as_magnitude<10>()), + kilogram> {}; struct neutron_mass : - named_scaled_unit(), kilogram> {}; + named_scaled_unit() * pow<-27>(as_magnitude<10>()), + kilogram> {}; struct dim_mass : isq::dim_mass {}; diff --git a/src/systems/si-hep/include/units/isq/si/hep/momentum.h b/src/systems/si-hep/include/units/isq/si/hep/momentum.h index c6791501..ab87fb4a 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/momentum.h +++ b/src/systems/si-hep/include/units/isq/si/hep/momentum.h @@ -41,7 +41,8 @@ namespace units::isq::si::hep { struct kilogram_metre_per_second : derived_unit {}; struct eV_per_c : - named_scaled_unit(), + named_scaled_unit() * pow<-35>(as_magnitude<10>()), kilogram_metre_per_second> {}; struct feV_per_c : prefixed_unit {}; struct peV_per_c : prefixed_unit {}; diff --git a/src/systems/si-iau/include/units/isq/si/iau/length.h b/src/systems/si-iau/include/units/isq/si/iau/length.h index d2e184a1..e4066edb 100644 --- a/src/systems/si-iau/include/units/isq/si/iau/length.h +++ b/src/systems/si-iau/include/units/isq/si/iau/length.h @@ -42,7 +42,7 @@ struct light_year : named_scaled_unit(), si::metre> {}; // https://en.wikipedia.org/wiki/Angstrom -struct angstrom : named_scaled_unit(), si::metre> {}; +struct angstrom : named_scaled_unit(as_magnitude<10>()), si::metre> {}; #ifndef UNITS_NO_LITERALS diff --git a/src/systems/si-international/include/units/isq/si/international/length.h b/src/systems/si-international/include/units/isq/si/international/length.h index b61bd2cf..5e3bab57 100644 --- a/src/systems/si-international/include/units/isq/si/international/length.h +++ b/src/systems/si-international/include/units/isq/si/international/length.h @@ -37,7 +37,7 @@ namespace units::isq::si::international { // si::international yard // https://en.wikipedia.org/wiki/International_yard_and_pound -struct yard : named_scaled_unit(), si::metre> {}; +struct yard : named_scaled_unit(), si::metre> {}; // si::international foot // https://en.wikipedia.org/wiki/Foot_(unit)#International_foot diff --git a/src/systems/si-typographic/include/units/isq/si/typographic/length.h b/src/systems/si-typographic/include/units/isq/si/typographic/length.h index e69c31c6..ecd56afd 100644 --- a/src/systems/si-typographic/include/units/isq/si/typographic/length.h +++ b/src/systems/si-typographic/include/units/isq/si/typographic/length.h @@ -38,11 +38,16 @@ 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(), si::metre> {}; -struct pica_prn : named_scaled_unit(), si::metre> {}; + named_scaled_unit() * pow<-9>(as_magnitude<10>()), si::metre> {}; +struct pica_prn : + named_scaled_unit() * pow<-3>(as_magnitude<10>()), + si::metre> {}; struct point_comp : - named_scaled_unit(), si::metre> {}; -struct point_prn : named_scaled_unit(), si::metre> {}; + named_scaled_unit() * pow<-4>(as_magnitude<10>()), + si::metre> {}; +struct point_prn : + named_scaled_unit() * pow<-4>(as_magnitude<10>()), + si::metre> {}; #ifndef UNITS_NO_LITERALS diff --git a/src/systems/si/include/units/isq/si/catalytic_activity.h b/src/systems/si/include/units/isq/si/catalytic_activity.h index 07ca426f..562eb0fa 100644 --- a/src/systems/si/include/units/isq/si/catalytic_activity.h +++ b/src/systems/si/include/units/isq/si/catalytic_activity.h @@ -58,7 +58,8 @@ struct exakatal : prefixed_unit {}; struct zettakatal : prefixed_unit {}; struct yottakatal : prefixed_unit {}; -struct enzyme_unit : named_scaled_unit(), katal> {}; +struct enzyme_unit : + named_scaled_unit() * pow<-6>(as_magnitude<10>()), katal> {}; struct dim_catalytic_activity : isq::dim_catalytic_activity {}; diff --git a/src/systems/si/include/units/isq/si/energy.h b/src/systems/si/include/units/isq/si/energy.h index cf0eba26..c9eca1cb 100644 --- a/src/systems/si/include/units/isq/si/energy.h +++ b/src/systems/si/include/units/isq/si/energy.h @@ -56,7 +56,8 @@ struct yottajoule : prefixed_unit {}; // 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(), joule> {}; + named_scaled_unit() * pow<-19>(as_magnitude<10>()), joule> {}; struct gigaelectronvolt : prefixed_unit {}; struct dim_energy : isq::dim_energy {}; diff --git a/src/systems/si/include/units/isq/si/mass.h b/src/systems/si/include/units/isq/si/mass.h index 53a574f4..e4d935d1 100644 --- a/src/systems/si/include/units/isq/si/mass.h +++ b/src/systems/si/include/units/isq/si/mass.h @@ -79,7 +79,9 @@ struct zettatonne : prefixed_unit {}; struct yottatonne : prefixed_unit {}; struct dalton : - named_scaled_unit(), kilogram> {}; + named_scaled_unit() * pow<-27>(as_magnitude<10>()), + kilogram> {}; struct dim_mass : isq::dim_mass {}; diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index cf346a27..a47c5782 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -579,8 +579,7 @@ static_assert(is_same_v>); -static_assert( - compare(), metre>, std::int64_t>>); +static_assert(compare(), metre>, std::int64_t>>); static_assert( compare, exponent>, scaled_unit(), unknown_coherent_unit>, std::int64_t>>); @@ -590,7 +589,7 @@ static_assert( static_assert(compare>); static_assert(compare>, - scaled_unit(), unknown_coherent_unit>, std::int64_t>>); + scaled_unit(), unknown_coherent_unit>, std::int64_t>>); static_assert(compare(), one>, std::int64_t>>); static_assert(compare>); static_assert( @@ -889,7 +888,7 @@ static_assert(is_same_v, units::exponent>, scaled_unit(), unknown_coherent_unit>, std::int64_t>>); static_assert( - is_same_v(), metre>, std::int64_t>>); + is_same_v(), metre>, std::int64_t>>); #else diff --git a/test/unit_test/static/unit_test.cpp b/test/unit_test/static/unit_test.cpp index 128fac3d..c4d4baf6 100644 --- a/test/unit_test/static/unit_test.cpp +++ b/test/unit_test/static/unit_test.cpp @@ -36,12 +36,12 @@ using namespace units::isq; struct metre : named_unit {}; struct centimetre : prefixed_unit {}; struct kilometre : prefixed_unit {}; -struct yard : named_scaled_unit(), metre> {}; +struct yard : named_scaled_unit(), metre> {}; struct foot : named_scaled_unit(), yard> {}; struct dim_length : base_dimension<"length", metre> {}; struct second : named_unit {}; -struct hour : named_scaled_unit(), second> {}; +struct hour : named_scaled_unit(), second> {}; struct dim_time : base_dimension<"time", second> {}; struct kelvin : named_unit {}; @@ -60,7 +60,7 @@ struct kilometre_per_hour : derived_scaled_unit); static_assert(equivalent); static_assert(compare(), metre>>, metre>); -static_assert(compare(), metre>>, centimetre>); +static_assert(compare(), metre>>, centimetre>); static_assert(compare>, yard>); static_assert(compare(), metre>>, foot>); static_assert(compare>, kilometre_per_hour>);