refactor: MSVC workarounds for named prefixed units definitions

This commit is contained in:
Mateusz Pusz
2024-01-05 11:17:03 +01:00
parent 9fd0438849
commit 09d923d619
4 changed files with 20 additions and 0 deletions

View File

@ -28,7 +28,11 @@
namespace mp_units::cgs { namespace mp_units::cgs {
// clang-format off // clang-format off
#if MP_UNITS_COMP_MSVC
inline constexpr struct centimetre : si::centi_<si::metre> {} centimetre;
#else
inline constexpr struct centimetre : decltype(si::centi<si::metre>) {} centimetre; inline constexpr struct centimetre : decltype(si::centi<si::metre>) {} centimetre;
#endif
inline constexpr struct gram : decltype(si::gram) {} gram; inline constexpr struct gram : decltype(si::gram) {} gram;
inline constexpr struct second : decltype(si::second) {} second; inline constexpr struct second : decltype(si::second) {} second;
inline constexpr struct gal : named_unit<"Gal", centimetre / square(second)> {} gal; inline constexpr struct gal : named_unit<"Gal", centimetre / square(second)> {} gal;

View File

@ -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; inline constexpr struct pound_force : named_unit<"lbf", pound * si::standard_gravity> {} pound_force;
// https://en.wikipedia.org/wiki/Kip_(unit), // https://en.wikipedia.org/wiki/Kip_(unit),
#if MP_UNITS_COMP_MSVC
inline constexpr struct kip : si::kilo_<pound_force> {} kip;
#else
inline constexpr struct kip : decltype(si::kilo<pound_force>) {} kip; inline constexpr struct kip : decltype(si::kilo<pound_force>) {} kip;
#endif
// pressure // pressure
inline constexpr struct psi : named_unit<"psi", pound_force / square(inch)> {} psi; inline constexpr struct psi : named_unit<"psi", pound_force / square(inch)> {} psi;

View File

@ -33,7 +33,11 @@ namespace mp_units::natural {
// clang-format off // clang-format off
// units // units
inline constexpr struct electronvolt : named_unit<"eV"> {} electronvolt; inline constexpr struct electronvolt : named_unit<"eV"> {} electronvolt;
#if MP_UNITS_COMP_MSVC
inline constexpr struct gigaelectronvolt : si::giga_<electronvolt> {} gigaelectronvolt;
#else
inline constexpr struct gigaelectronvolt : decltype(si::giga<electronvolt>) {} gigaelectronvolt; inline constexpr struct gigaelectronvolt : decltype(si::giga<electronvolt>) {} gigaelectronvolt;
#endif
// system references // system references
inline constexpr struct time : system_reference<isq::time, inverse(gigaelectronvolt)> {} time; inline constexpr struct time : system_reference<isq::time, inverse(gigaelectronvolt)> {} time;

View File

@ -38,7 +38,11 @@ namespace si {
inline constexpr struct second : named_unit<"s", kind_of<isq::time>> {} second; inline constexpr struct second : named_unit<"s", kind_of<isq::time>> {} second;
inline constexpr struct metre : named_unit<"m", kind_of<isq::length>> {} metre; inline constexpr struct metre : named_unit<"m", kind_of<isq::length>> {} metre;
inline constexpr struct gram : named_unit<"g", kind_of<isq::mass>> {} gram; inline constexpr struct gram : named_unit<"g", kind_of<isq::mass>> {} gram;
#if MP_UNITS_COMP_MSVC
inline constexpr struct kilogram : kilo_<gram> {} kilogram;
#else
inline constexpr struct kilogram : decltype(kilo<gram>) {} kilogram; inline constexpr struct kilogram : decltype(kilo<gram>) {} kilogram;
#endif
inline constexpr struct ampere : named_unit<"A", kind_of<isq::electric_current>> {} ampere; inline constexpr struct ampere : named_unit<"A", kind_of<isq::electric_current>> {} ampere;
inline constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero; inline constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero;
@ -100,7 +104,11 @@ inline constexpr struct degree : named_unit<basic_symbol_text{"°", "deg"}, mag_
inline constexpr struct arcminute : named_unit<basic_symbol_text{"", "'"}, mag<ratio{1, 60}> * degree> {} arcminute; inline constexpr struct arcminute : named_unit<basic_symbol_text{"", "'"}, mag<ratio{1, 60}> * degree> {} arcminute;
inline constexpr struct arcsecond : named_unit<basic_symbol_text{"", "''"}, mag<ratio{1, 60}> * arcminute> {} arcsecond; inline constexpr struct arcsecond : named_unit<basic_symbol_text{"", "''"}, mag<ratio{1, 60}> * arcminute> {} arcsecond;
inline constexpr struct are : named_unit<"a", square(si::deca<si::metre>)> {} are; inline constexpr struct are : named_unit<"a", square(si::deca<si::metre>)> {} are;
#if MP_UNITS_COMP_MSVC
inline constexpr struct hectare : si::hecto_<are> {} hectare;
#else
inline constexpr struct hectare : decltype(si::hecto<are>) {} hectare; inline constexpr struct hectare : decltype(si::hecto<are>) {} hectare;
#endif
inline constexpr struct litre : named_unit<"l", cubic(si::deci<si::metre>)> {} litre; inline constexpr struct litre : named_unit<"l", cubic(si::deci<si::metre>)> {} litre;
inline constexpr struct tonne : named_unit<"t", mag<1000> * si::kilogram> {} tonne; 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; 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;