From 09d923d619bad85cdae30c54ccebfdd12883f4e8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 5 Jan 2024 11:17:03 +0100 Subject: [PATCH] refactor: MSVC workarounds for named prefixed units definitions --- src/systems/cgs/include/mp-units/systems/cgs/cgs.h | 4 ++++ .../mp-units/systems/international/international.h | 4 ++++ .../natural/include/mp-units/systems/natural/natural.h | 4 ++++ src/systems/si/include/mp-units/systems/si/units.h | 8 ++++++++ 4 files changed, 20 insertions(+) diff --git a/src/systems/cgs/include/mp-units/systems/cgs/cgs.h b/src/systems/cgs/include/mp-units/systems/cgs/cgs.h index 9e91b6da8..7c59c700c 100644 --- a/src/systems/cgs/include/mp-units/systems/cgs/cgs.h +++ b/src/systems/cgs/include/mp-units/systems/cgs/cgs.h @@ -28,7 +28,11 @@ 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 struct gal : named_unit<"Gal", centimetre / square(second)> {} gal; diff --git a/src/systems/international/include/mp-units/systems/international/international.h b/src/systems/international/include/mp-units/systems/international/international.h index dc0731f6a..db9e3330e 100644 --- a/src/systems/international/include/mp-units/systems/international/international.h +++ b/src/systems/international/include/mp-units/systems/international/international.h @@ -59,7 +59,11 @@ 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 // pressure inline constexpr struct psi : named_unit<"psi", pound_force / square(inch)> {} psi; diff --git a/src/systems/natural/include/mp-units/systems/natural/natural.h b/src/systems/natural/include/mp-units/systems/natural/natural.h index b07386109..5221dada9 100644 --- a/src/systems/natural/include/mp-units/systems/natural/natural.h +++ b/src/systems/natural/include/mp-units/systems/natural/natural.h @@ -33,7 +33,11 @@ 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 // system references inline constexpr struct time : system_reference {} time; diff --git a/src/systems/si/include/mp-units/systems/si/units.h b/src/systems/si/include/mp-units/systems/si/units.h index 8936df818..2167075ee 100644 --- a/src/systems/si/include/mp-units/systems/si/units.h +++ b/src/systems/si/include/mp-units/systems/si/units.h @@ -38,7 +38,11 @@ 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 struct ampere : named_unit<"A", kind_of> {} ampere; inline constexpr struct absolute_zero : absolute_point_origin {} absolute_zero; @@ -100,7 +104,11 @@ 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 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 * mag_power<10, -27> * si::kilogram> {} dalton;