diff --git a/docs/users_guide/framework_basics/text_output.md b/docs/users_guide/framework_basics/text_output.md index de8c96ea..67bd4395 100644 --- a/docs/users_guide/framework_basics/text_output.md +++ b/docs/users_guide/framework_basics/text_output.md @@ -48,7 +48,7 @@ and units of derived quantities. inline constexpr struct second : named_unit<"s", kind_of> {} second; inline constexpr struct metre : named_unit<"m", kind_of> {} metre; inline constexpr struct gram : named_unit<"g", kind_of> {} gram; - inline constexpr struct kilogram : decltype(kilo) {} kilogram; + inline constexpr auto kilogram = kilo; inline constexpr struct newton : named_unit<"N", kilogram * metre / square(second)> {} newton; inline constexpr struct joule : named_unit<"J", newton * metre> {} joule; diff --git a/src/systems/include/mp-units/systems/cgs.h b/src/systems/include/mp-units/systems/cgs.h index f3e58e54..4a3645f5 100644 --- a/src/systems/include/mp-units/systems/cgs.h +++ b/src/systems/include/mp-units/systems/cgs.h @@ -35,13 +35,9 @@ MP_UNITS_EXPORT namespace mp_units::cgs { // clang-format off -#if MP_UNITS_COMP_MSVC -inline constexpr struct centimetre : si::centi_ {} centimetre; -#else -inline constexpr struct centimetre : decltype(si::centi) {} centimetre; -#endif -inline constexpr struct gram : decltype(si::gram) {} gram; -inline constexpr struct second : decltype(si::second) {} second; +inline constexpr auto centimetre = si::centi; +inline constexpr auto gram = si::gram; +inline constexpr auto second = si::second; inline constexpr struct gal : named_unit<"Gal", centimetre / square(second)> {} gal; inline constexpr struct dyne : named_unit<"dyn", gram * centimetre / square(second)> {} dyne; inline constexpr struct erg : named_unit<"erg", dyne * centimetre> {} erg; diff --git a/src/systems/include/mp-units/systems/hep.h b/src/systems/include/mp-units/systems/hep.h index 0267042f..6020d07f 100644 --- a/src/systems/include/mp-units/systems/hep.h +++ b/src/systems/include/mp-units/systems/hep.h @@ -57,7 +57,7 @@ inline constexpr struct proton_mass : named_unit<"m_p", mag_ratio<1'672'621'923' 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; +inline constexpr auto speed_of_light = si::si2019::speed_of_light_in_vacuum; // clang-format on namespace unit_symbols { diff --git a/src/systems/include/mp-units/systems/iau.h b/src/systems/include/mp-units/systems/iau.h index 8d4aeaa8..804f2ed0 100644 --- a/src/systems/include/mp-units/systems/iau.h +++ b/src/systems/include/mp-units/systems/iau.h @@ -50,7 +50,7 @@ inline constexpr struct Jupiter_mass : named_unit<"M_JUP", mag_ratio<1'898, 1'00 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; +inline constexpr auto astronomical_unit = si::astronomical_unit; // https://en.wikipedia.org/wiki/Lunar_distance_(astronomy) inline constexpr struct lunar_distance : named_unit<"LD", mag<384'399> * si::kilo> {} lunar_distance; diff --git a/src/systems/include/mp-units/systems/imperial.h b/src/systems/include/mp-units/systems/imperial.h index 4398a8f5..ffdd4002 100644 --- a/src/systems/include/mp-units/systems/imperial.h +++ b/src/systems/include/mp-units/systems/imperial.h @@ -54,9 +54,9 @@ inline constexpr struct link : named_unit<"li", mag_ratio<1, 100> * chain> {} li inline constexpr struct rod : named_unit<"rd", mag<25> * link> {} rod; // https://en.wikipedia.org/wiki/Imperial_units#Area -inline constexpr struct perch : decltype(square(rod)) {} perch; -inline constexpr struct rood : decltype(mag<40> * perch) {} rood; -inline constexpr struct acre : decltype(mag<4> * rood) {} acre; +inline constexpr struct perch : named_unit<"perch", square(rod)> {} perch; +inline constexpr struct rood : named_unit<"rood", mag<40> * perch> {} rood; +inline constexpr struct acre : named_unit<"acre", 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; diff --git a/src/systems/include/mp-units/systems/international.h b/src/systems/include/mp-units/systems/international.h index 0b680ce3..d4de6a31 100644 --- a/src/systems/include/mp-units/systems/international.h +++ b/src/systems/include/mp-units/systems/international.h @@ -67,11 +67,7 @@ inline constexpr struct poundal : named_unit<"pdl", pound * foot / square(si::se inline constexpr struct pound_force : named_unit<"lbf", pound * si::standard_gravity> {} pound_force; // https://en.wikipedia.org/wiki/Kip_(unit), -#if MP_UNITS_COMP_MSVC -inline constexpr struct kip : si::kilo_ {} kip; -#else -inline constexpr struct kip : decltype(si::kilo) {} kip; -#endif +inline constexpr auto kip = si::kilo; // pressure inline constexpr struct psi : named_unit<"psi", pound_force / square(inch)> {} psi; diff --git a/src/systems/include/mp-units/systems/natural.h b/src/systems/include/mp-units/systems/natural.h index b56ee725..35f63339 100644 --- a/src/systems/include/mp-units/systems/natural.h +++ b/src/systems/include/mp-units/systems/natural.h @@ -39,11 +39,7 @@ namespace mp_units::natural { // clang-format off // units inline constexpr struct electronvolt : named_unit<"eV"> {} electronvolt; -#if MP_UNITS_COMP_MSVC -inline constexpr struct gigaelectronvolt : si::giga_ {} gigaelectronvolt; -#else -inline constexpr struct gigaelectronvolt : decltype(si::giga) {} gigaelectronvolt; -#endif +inline constexpr auto gigaelectronvolt = si::giga; // system references inline constexpr struct time : system_reference {} time; diff --git a/src/systems/include/mp-units/systems/si/units.h b/src/systems/include/mp-units/systems/si/units.h index 36d7772f..72b16ba3 100644 --- a/src/systems/include/mp-units/systems/si/units.h +++ b/src/systems/include/mp-units/systems/si/units.h @@ -41,11 +41,7 @@ namespace si { inline constexpr struct second : named_unit<"s", kind_of> {} second; inline constexpr struct metre : named_unit<"m", kind_of> {} metre; inline constexpr struct gram : named_unit<"g", kind_of> {} gram; -#if MP_UNITS_COMP_MSVC -inline constexpr struct kilogram : kilo_ {} kilogram; -#else -inline constexpr struct kilogram : decltype(kilo) {} kilogram; -#endif +inline constexpr auto kilogram = kilo; inline constexpr struct ampere : named_unit<"A", kind_of> {} ampere; inline constexpr struct absolute_zero : absolute_point_origin {} absolute_zero; @@ -107,11 +103,7 @@ inline constexpr struct degree : named_unit * degree> {} arcminute; inline constexpr struct arcsecond : named_unit * arcminute> {} arcsecond; inline constexpr struct are : named_unit<"a", square(si::deca)> {} are; -#if MP_UNITS_COMP_MSVC -inline constexpr struct hectare : si::hecto_ {} hectare; -#else -inline constexpr struct hectare : decltype(si::hecto) {} hectare; -#endif +inline constexpr auto hectare = si::hecto; inline constexpr struct litre : named_unit<"l", cubic(si::deci)> {} litre; inline constexpr struct tonne : named_unit<"t", mag<1000> * si::kilogram> {} tonne; inline constexpr struct dalton : named_unit<"Da", mag_ratio<16'605'390'666'050, 10'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} dalton; diff --git a/src/systems/include/mp-units/systems/usc.h b/src/systems/include/mp-units/systems/usc.h index cfa2eb76..87c7ace5 100644 --- a/src/systems/include/mp-units/systems/usc.h +++ b/src/systems/include/mp-units/systems/usc.h @@ -94,7 +94,7 @@ inline constexpr struct minim : named_unit<"min", mag_ratio<1, 80> * teaspoon> { inline constexpr struct fluid_dram : named_unit<"fl dr", mag<60> * minim> {} fluid_dram; inline constexpr struct barrel : named_unit<"bbl", mag_ratio<315, 10> * gallon> {} barrel; inline constexpr struct oil_barrel : named_unit<"bbl", mag_ratio<4, 3> * barrel> {} oil_barrel; -inline constexpr struct hogshead : decltype(mag<63> * gallon) {} hogshead; +inline constexpr struct hogshead : named_unit<"hogshead", mag<63> * gallon> {} hogshead; // https://en.wikipedia.org/wiki/United_States_customary_units#Dry_volume inline constexpr struct dry_barrel : named_unit<"bbl", mag<7056> * cubic(inch)> {} dry_barrel; diff --git a/test/static/concepts_test.cpp b/test/static/concepts_test.cpp index 68033efa..85e5a58c 100644 --- a/test/static/concepts_test.cpp +++ b/test/static/concepts_test.cpp @@ -141,7 +141,7 @@ static_assert(!detail::QuantityKindSpec); struct metre_per_second : decltype(si::metre / si::second) {}; static_assert(Unit); -static_assert(Unit); +static_assert(Unit); static_assert(Unit)>); static_assert(Unit); static_assert(Unit); @@ -168,7 +168,7 @@ static_assert(!Unit); // NamedUnit static_assert(detail::NamedUnit); static_assert(detail::NamedUnit); -static_assert(!detail::NamedUnit); +static_assert(!detail::NamedUnit); static_assert(!detail::NamedUnit)>); static_assert(!detail::NamedUnit); static_assert(!detail::NamedUnit); @@ -194,7 +194,7 @@ static_assert(!detail::NamedUnit); // PrefixableUnit static_assert(PrefixableUnit); static_assert(PrefixableUnit); -static_assert(!PrefixableUnit); +static_assert(!PrefixableUnit); static_assert(!PrefixableUnit)>); static_assert(!PrefixableUnit); static_assert(!PrefixableUnit); @@ -220,7 +220,7 @@ static_assert(!PrefixableUnit); // AssociatedUnit static_assert(AssociatedUnit); static_assert(!AssociatedUnit); -static_assert(AssociatedUnit); +static_assert(AssociatedUnit); static_assert(AssociatedUnit)>); static_assert(AssociatedUnit); static_assert(AssociatedUnit); @@ -246,7 +246,7 @@ static_assert(!AssociatedUnit); // UnitOf static_assert(UnitOf); static_assert(UnitOf); -static_assert(UnitOf); +static_assert(UnitOf); static_assert(UnitOf); static_assert(UnitOf); static_assert(UnitOf);