forked from mpusz/mp-units
refactor: square and cubic are now functions (not variable templates)
This commit is contained in:
@@ -37,7 +37,7 @@ 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<basic_symbol_text{"°", "deg"}, mag<ratio{1, 360}> * revolution> {} degree;
|
||||
inline constexpr struct gradian : named_unit<basic_symbol_text{"ᵍ", "grad"}, mag<ratio{1, 400}> * revolution> {} gradian;
|
||||
inline constexpr struct steradian : named_unit<"sr", square<radian>> {} steradian;
|
||||
inline constexpr struct steradian : named_unit<"sr", square(radian)> {} steradian;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
@@ -47,8 +47,8 @@ inline constexpr auto rev = revolution;
|
||||
inline constexpr auto deg = degree;
|
||||
inline constexpr auto grad = gradian;
|
||||
inline constexpr auto sr = steradian;
|
||||
inline constexpr auto rad2 = square<radian>;
|
||||
inline constexpr auto deg2 = square<degree>;
|
||||
inline constexpr auto rad2 = square(radian);
|
||||
inline constexpr auto deg2 = square(degree);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace mp_units::cgs {
|
||||
inline constexpr struct centimetre : decltype(si::centi<si::metre>) {} centimetre;
|
||||
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;
|
||||
inline constexpr struct dyne : named_unit<"dyn", gram * centimetre / square<second>> {} dyne;
|
||||
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;
|
||||
inline constexpr struct barye : named_unit<"Ba", gram / (centimetre * square<second>)> {} barye;
|
||||
inline constexpr struct barye : named_unit<"Ba", gram / (centimetre * square(second))> {} barye;
|
||||
inline constexpr struct poise : named_unit<"P", gram / (centimetre * second)> {} poise;
|
||||
inline constexpr struct stokes : named_unit<"St", square<centimetre> / second> {} stokes;
|
||||
inline constexpr struct stokes : named_unit<"St", square(centimetre) / second> {} stokes;
|
||||
inline constexpr struct kayser : named_unit<"K", 1 / centimetre> {} kayser;
|
||||
// clang-format on
|
||||
|
||||
@@ -53,10 +53,10 @@ inline constexpr auto St = stokes;
|
||||
inline constexpr auto K = kayser;
|
||||
|
||||
// commonly used squared and cubic units
|
||||
inline constexpr auto cm2 = square<centimetre>;
|
||||
inline constexpr auto cm3 = cubic<centimetre>;
|
||||
inline constexpr auto s2 = square<second>;
|
||||
inline constexpr auto s3 = cubic<second>;
|
||||
inline constexpr auto cm2 = square(centimetre);
|
||||
inline constexpr auto cm3 = cubic(centimetre);
|
||||
inline constexpr auto s2 = square(second);
|
||||
inline constexpr auto s3 = cubic(second);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ using si::electronvolt;
|
||||
// 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
|
||||
inline constexpr struct barn : named_unit<"b", mag_power<10, -28> * square<si::metre>> {} barn;
|
||||
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;
|
||||
@@ -90,7 +90,7 @@ inline constexpr auto m_p = proton_mass;
|
||||
inline constexpr auto m_n = neutron_mass;
|
||||
|
||||
inline constexpr auto c = si::si2019::speed_of_light_in_vacuum_unit;
|
||||
inline constexpr auto c2 = square<si::si2019::speed_of_light_in_vacuum_unit>;
|
||||
inline constexpr auto c2 = square(si::si2019::speed_of_light_in_vacuum_unit);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ inline constexpr struct link : named_unit<"li", mag<ratio{1, 100}> * chain> {} l
|
||||
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 perch : decltype(square(rod)) {} perch;
|
||||
inline constexpr struct rood : decltype(mag<40> * perch) {} rood;
|
||||
inline constexpr struct acre : decltype(mag<4> * rood) {} acre;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ inline constexpr struct knot : named_unit<"kn", nautical_mile / si::hour> {} kno
|
||||
|
||||
// force
|
||||
// https://en.wikipedia.org/wiki/Poundal
|
||||
inline constexpr struct poundal : named_unit<"pdl", pound * foot / square<si::second>> {} poundal;
|
||||
inline constexpr struct poundal : named_unit<"pdl", pound * foot / square(si::second)> {} poundal;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Pound_(force)
|
||||
inline constexpr struct pound_force : named_unit<"lbf", pound * si::standard_gravity_unit> {} pound_force;
|
||||
@@ -61,7 +61,7 @@ inline constexpr struct pound_force : named_unit<"lbf", pound * si::standard_gra
|
||||
inline constexpr struct kip : decltype(si::kilo<pound_force>) {} kip;
|
||||
|
||||
// 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;
|
||||
|
||||
// power
|
||||
// https://en.wikipedia.org/wiki/Horsepower#Definitions
|
||||
|
||||
@@ -43,7 +43,7 @@ inline constexpr struct velocity : system_reference<isq::velocity, one> {} veloc
|
||||
inline constexpr struct speed : system_reference<isq::speed, one> {} speed;
|
||||
inline constexpr struct acceleration : system_reference<isq::acceleration, gigaelectronvolt> {} acceleration;
|
||||
inline constexpr struct momentum : system_reference<isq::momentum, gigaelectronvolt> {} momentum;
|
||||
inline constexpr struct force : system_reference<isq::force, square<gigaelectronvolt>> {} force;
|
||||
inline constexpr struct force : system_reference<isq::force, square(gigaelectronvolt)> {} force;
|
||||
inline constexpr struct energy : system_reference<isq::mechanical_energy, gigaelectronvolt> {} energy;
|
||||
// clang-format on
|
||||
|
||||
@@ -53,7 +53,7 @@ inline constexpr auto speed_of_light_in_vacuum = speed[one];
|
||||
namespace unit_symbols {
|
||||
|
||||
inline constexpr auto GeV = gigaelectronvolt;
|
||||
inline constexpr auto GeV2 = square<gigaelectronvolt>;
|
||||
inline constexpr auto GeV2 = square(gigaelectronvolt);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ inline constexpr auto avogadro_constant = (1 / isq::amount_of_substance)[avogadr
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct standard_gravity_unit :
|
||||
constant_unit<basic_symbol_text{"g₀", "g_0"}, mag<ratio{980'665, 100'000}> * metre / square<second>> {} standard_gravity_unit;
|
||||
constant_unit<basic_symbol_text{"g₀", "g_0"}, mag<ratio{980'665, 100'000}> * metre / square(second)> {} standard_gravity_unit;
|
||||
inline constexpr struct magnetic_constant_unit :
|
||||
constant_unit<basic_symbol_text{"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant_unit;
|
||||
// clang-format on
|
||||
|
||||
@@ -747,10 +747,10 @@ inline constexpr auto h = hour;
|
||||
inline constexpr auto d = day;
|
||||
|
||||
// commonly used squared and cubic units
|
||||
inline constexpr auto m2 = square<metre>;
|
||||
inline constexpr auto m3 = cubic<metre>;
|
||||
inline constexpr auto m2 = square(metre);
|
||||
inline constexpr auto m3 = cubic(metre);
|
||||
inline constexpr auto m4 = pow<4>(metre);
|
||||
inline constexpr auto s2 = square<second>;
|
||||
inline constexpr auto s3 = cubic<second>;
|
||||
inline constexpr auto s2 = square(second);
|
||||
inline constexpr auto s3 = cubic(second);
|
||||
|
||||
} // namespace mp_units::si::unit_symbols
|
||||
|
||||
@@ -42,15 +42,15 @@ inline constexpr struct candela : named_unit<"cd", kind_of<isq::luminous_intensi
|
||||
|
||||
// derived named units
|
||||
inline constexpr struct radian : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian;
|
||||
inline constexpr struct steradian : named_unit<"sr", square<metre> / square<metre>, kind_of<isq::solid_angular_measure>> {} steradian;
|
||||
inline constexpr struct steradian : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian;
|
||||
inline constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;
|
||||
inline constexpr struct newton : named_unit<"N", kilogram * metre / square<second>> {} newton;
|
||||
inline constexpr struct newton : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
#ifdef pascal
|
||||
#pragma push_macro("pascal")
|
||||
#undef pascal
|
||||
#define UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
inline constexpr struct pascal : named_unit<"Pa", newton / square<metre>> {} pascal;
|
||||
inline constexpr struct pascal : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
#ifdef UNITS_REDEFINE_PASCAL
|
||||
#pragma pop_macro("pascal")
|
||||
#undef UNITS_REDEFINE_PASCAL
|
||||
@@ -63,12 +63,12 @@ inline constexpr struct farad : named_unit<"F", coulomb / volt> {} farad;
|
||||
inline constexpr struct ohm : named_unit<basic_symbol_text{"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct siemens : named_unit<"S", 1 / ohm> {} siemens;
|
||||
inline constexpr struct weber : named_unit<"Wb", volt * second> {} weber;
|
||||
inline constexpr struct tesla : named_unit<"T", weber / square<metre>> {} tesla;
|
||||
inline constexpr struct tesla : named_unit<"T", weber / square(metre)> {} tesla;
|
||||
inline constexpr struct henry : named_unit<"H", weber / ampere> {} henry;
|
||||
// inline constexpr struct degree_Celsius : named_unit<basic_symbol_text{"°C", "`C"}, kelvin, offset<-mag<273150> * milli<kelvin>, only_for<isq::Celsius_temperature> {} degree_Celsius;
|
||||
inline constexpr struct degree_Celsius : named_unit<basic_symbol_text{"°C", "`C"}, kelvin> {} degree_Celsius;
|
||||
inline constexpr struct lumen : named_unit<"lm", candela * steradian> {} lumen;
|
||||
inline constexpr struct lux : named_unit<"lx", lumen / square<metre>> {} lux;
|
||||
inline constexpr struct lux : named_unit<"lx", lumen / square(metre)> {} lux;
|
||||
// inline constexpr struct becquerel : named_unit<"Bq", 1 / second, kind_of<activity>> {} becquerel;
|
||||
inline constexpr struct becquerel : named_unit<"Bq", 1 / second> {} becquerel;
|
||||
inline constexpr struct gray : named_unit<"Gy", joule / kilogram> {} gray;
|
||||
@@ -84,9 +84,9 @@ inline constexpr struct degree : named_unit<basic_symbol_text{"°", "deg"}, mag_
|
||||
// TODO how to disambiguate below angular units from time units (inline namespace `plane_angle`?)
|
||||
// inline constexpr struct minute : named_unit<basic_symbol_text{"′", "'"}, mag<ratio{1, 60}> * degree> {} minute;
|
||||
// inline constexpr struct second : named_unit<basic_symbol_text{"″", "''"}, mag<ratio{1, 60}> * minute> {} second;
|
||||
inline constexpr struct are : named_unit<"a", square<deca<metre>>> {} are;
|
||||
inline constexpr struct are : named_unit<"a", square(deca<metre>)> {} are;
|
||||
inline constexpr struct hectare : decltype(hecto<are>) {} hectare;
|
||||
inline constexpr struct litre : named_unit<"l", cubic<deci<metre>>> {} litre;
|
||||
inline constexpr struct litre : named_unit<"l", cubic(deci<metre>)> {} litre;
|
||||
inline constexpr struct tonne : named_unit<"t", mag<1000> * 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> * kilogram> {} dalton;
|
||||
// TODO A different value is provided in the SI Brochure and different in the ISO 80000
|
||||
|
||||
@@ -68,11 +68,11 @@ inline constexpr struct league : named_unit<"lea", mag<3> * us_survey_mile> {} l
|
||||
|
||||
// clang-format off
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Area
|
||||
inline constexpr struct acre : named_unit<"acre", mag<10> * square<survey1893::chain>> {} acre;
|
||||
inline constexpr struct acre : named_unit<"acre", mag<10> * square(survey1893::chain)> {} acre;
|
||||
inline constexpr struct section : named_unit<"section", mag<640> * acre> {} section;
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Fluid_volume
|
||||
inline constexpr struct gallon : named_unit<"gal", mag<231> * cubic<inch>> {} gallon;
|
||||
inline constexpr struct gallon : named_unit<"gal", mag<231> * cubic(inch)> {} gallon;
|
||||
inline constexpr struct pottle : named_unit<"pot", mag<ratio{1, 2}> * gallon> {} pottle;
|
||||
inline constexpr struct quart : named_unit<"qt", mag<ratio{1, 2}> * pottle> {} quart;
|
||||
inline constexpr struct pint : named_unit<"pt", mag<ratio{1, 2}> * quart> {} pint;
|
||||
@@ -89,7 +89,7 @@ inline constexpr struct oil_barrel : named_unit<"bbl", mag<ratio{4, 3}> * barrel
|
||||
inline constexpr struct hogshead : decltype(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;
|
||||
inline constexpr struct dry_barrel : named_unit<"bbl", mag<7056> * cubic(inch)> {} dry_barrel;
|
||||
inline constexpr struct bushel : named_unit<"bu", mag<ratio{3'523'907'016'688, 100'000'000'000}> * si::litre> {} bushel;
|
||||
inline constexpr struct peck : named_unit<"pk", mag<ratio{1, 4}> * bushel> {} peck;
|
||||
inline constexpr struct dry_gallon : named_unit<"gal", mag<ratio{1, 2}> * peck> {} dry_gallon;
|
||||
|
||||
Reference in New Issue
Block a user