mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 18:37:15 +02:00
refactor: square
and cubic
are now functions (not variable templates)
This commit is contained in:
@ -126,7 +126,7 @@ void calcs_comparison()
|
||||
|
||||
std::cout << "In multiplication and division:\n\n";
|
||||
|
||||
const quantity<isq::area[square<fm>], float> ArA = L1A * L2A;
|
||||
const quantity<isq::area[square(fm)], float> ArA = L1A * L2A;
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
|
||||
std::cout << "similar problems arise\n\n";
|
||||
|
@ -58,7 +58,7 @@ auto fmt_line(const Q& q)
|
||||
// Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI
|
||||
void print_details(std::string_view description, const Ship& ship)
|
||||
{
|
||||
const auto waterDensity = 62.4 * isq::density[lb / cubic<ft>];
|
||||
const auto waterDensity = 62.4 * isq::density[lb / cubic(ft)];
|
||||
std::cout << UNITS_STD_FMT::format("{}\n", description);
|
||||
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line<yd, m>(ship.length))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line<yd, m>(ship.draft))
|
||||
|
@ -78,7 +78,7 @@ inline constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true
|
||||
* inline constexpr struct second : named_unit<"s", time> {} second;
|
||||
* inline constexpr struct metre : named_unit<"m", length> {} metre;
|
||||
* inline constexpr struct hertz : named_unit<"Hz", 1 / second> {} 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;
|
||||
* inline constexpr struct degree_Celsius : named_unit<basic_symbol_text{"°C", "`C"}, kelvin> {} degree_Celsius;
|
||||
* inline constexpr struct minute : named_unit<"min", mag<60> * second> {} minute;
|
||||
* @endcode
|
||||
@ -180,7 +180,7 @@ struct named_unit<Symbol, U, QS> : std::remove_const_t<decltype(U)> {
|
||||
*
|
||||
* @code{.cpp}
|
||||
* inline constexpr struct standard_gravity_unit :
|
||||
* constant_unit<"g", mag<ratio{980'665, 100'000}> * metre / square<second>> {} standard_gravity_unit;
|
||||
* constant_unit<"g", mag<ratio{980'665, 100'000}> * metre / square(second)> {} standard_gravity_unit;
|
||||
* @endcode
|
||||
*
|
||||
* @note A common convention in this library is to assign the same name for a type and an object of this type.
|
||||
@ -253,7 +253,7 @@ struct is_one : std::false_type {};
|
||||
* static_assert(is_of_type<metre * metre, derived_unit<power<metre, 2>>>);
|
||||
* static_assert(is_of_type<metre * second, derived_unit<metre, second>>);
|
||||
* static_assert(is_of_type<metre / second, derived_unit<metre, per<second>>>);
|
||||
* static_assert(is_of_type<metre / square<second>, derived_unit<metre, per<power<second, 2>>>>);
|
||||
* static_assert(is_of_type<metre / square(second), derived_unit<metre, per<power<second, 2>>>>);
|
||||
* static_assert(is_of_type<watt / joule, derived_unit<watt, per<joule>>>);
|
||||
* @endcode
|
||||
*
|
||||
@ -564,18 +564,30 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
|
||||
else
|
||||
return derived_unit<power<U, Num, Den>>{};
|
||||
} else if constexpr (detail::is_specialization_of_scaled_unit<U>) {
|
||||
return scaled_unit<pow<ratio{Num, Den}>(U::mag), std::remove_const_t<decltype(pow<Num, Den>(U::reference_unit))>>{};
|
||||
return scaled_unit<pow<Num, Den>(U::mag), std::remove_const_t<decltype(pow<Num, Den>(U::reference_unit))>>{};
|
||||
} else {
|
||||
return detail::expr_pow<Num, Den, derived_unit, struct one, detail::type_list_of_unit_less>(u);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper variable templates to create common powers
|
||||
template<Unit auto U>
|
||||
inline constexpr decltype(U * U) square;
|
||||
/**
|
||||
* @brief Computes the square power of a unit
|
||||
*
|
||||
* @param u Unit being the base of the operation
|
||||
*
|
||||
* @return Unit The result of computation
|
||||
*/
|
||||
[[nodiscard]] consteval Unit auto square(Unit auto u) { return pow<2>(u); }
|
||||
|
||||
/**
|
||||
* @brief Computes the cubic power of a unit
|
||||
*
|
||||
* @param u Unit being the base of the operation
|
||||
*
|
||||
* @return Unit The result of computation
|
||||
*/
|
||||
[[nodiscard]] consteval Unit auto cubic(Unit auto u) { return pow<3>(u); }
|
||||
|
||||
template<Unit auto U>
|
||||
inline constexpr decltype(U * U * U) cubic;
|
||||
|
||||
// common dimensionless units
|
||||
// clang-format off
|
||||
|
@ -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;
|
||||
|
@ -40,13 +40,13 @@ static_assert(isq::length(100 * cm) == isq::length(1 * si::metre));
|
||||
static_assert(isq::mass(1000 * g) == isq::mass(1 * si::kilogram));
|
||||
static_assert(isq::time(1 * s) == isq::time(1 * si::second));
|
||||
static_assert(isq::speed(100 * (cm / s)) == isq::speed(1 * (si::metre / si::second)));
|
||||
static_assert(isq::acceleration(100 * Gal) == isq::acceleration(1 * (si::metre / square<si::second>)));
|
||||
static_assert(isq::acceleration(100 * Gal) == isq::acceleration(1 * (si::metre / square(si::second))));
|
||||
static_assert(isq::force(100'000 * dyn) == isq::force(1 * si::newton));
|
||||
static_assert(isq::energy(10'000'000 * erg) == isq::energy(1 * si::joule));
|
||||
static_assert(isq::power(10'000'000 * (erg / s)) == isq::power(1 * si::watt));
|
||||
static_assert(isq::pressure(10 * Ba) == isq::pressure(1 * si::pascal));
|
||||
static_assert(isq::dynamic_viscosity(10 * P) == isq::dynamic_viscosity(1 * (si::pascal * si::second)));
|
||||
static_assert(isq::kinematic_viscosity(10'000 * St) == isq::kinematic_viscosity(1 * (square<si::metre> / si::second)));
|
||||
static_assert(isq::kinematic_viscosity(10'000 * St) == isq::kinematic_viscosity(1 * (square(si::metre) / si::second)));
|
||||
static_assert(isq::wavenumber(1 * K) == isq::wavenumber(100 * (1 / si::metre)));
|
||||
|
||||
} // namespace
|
||||
|
@ -146,7 +146,7 @@ static_assert(Unit<struct natural::electronvolt>);
|
||||
static_assert(Unit<std::remove_const_t<decltype(si::metre / si::second)>>);
|
||||
static_assert(Unit<std::remove_const_t<decltype(1 / si::second)>>);
|
||||
static_assert(Unit<std::remove_const_t<decltype(mag<10> * si::second)>>);
|
||||
static_assert(Unit<std::remove_const_t<decltype(square<si::metre>)>>);
|
||||
static_assert(Unit<std::remove_const_t<decltype(square(si::metre))>>);
|
||||
static_assert(Unit<std::remove_const_t<decltype(pow<2>(si::metre))>>);
|
||||
static_assert(Unit<struct si::standard_gravity_unit>);
|
||||
static_assert(Unit<scaled_unit<mag<10>, struct si::second>>);
|
||||
@ -171,7 +171,7 @@ static_assert(!detail::NamedUnit<std::remove_const_t<decltype(si::kilo<si::gram>
|
||||
static_assert(!detail::NamedUnit<std::remove_const_t<decltype(si::metre / si::second)>>);
|
||||
static_assert(!detail::NamedUnit<std::remove_const_t<decltype(1 / si::second)>>);
|
||||
static_assert(!detail::NamedUnit<std::remove_const_t<decltype(mag<10> * si::second)>>);
|
||||
static_assert(!detail::NamedUnit<std::remove_const_t<decltype(square<si::metre>)>>);
|
||||
static_assert(!detail::NamedUnit<std::remove_const_t<decltype(square(si::metre))>>);
|
||||
static_assert(!detail::NamedUnit<std::remove_const_t<decltype(pow<2>(si::metre))>>);
|
||||
static_assert(!detail::NamedUnit<struct si::standard_gravity_unit>);
|
||||
static_assert(!detail::NamedUnit<scaled_unit<mag<10>, struct si::second>>);
|
||||
@ -196,7 +196,7 @@ static_assert(!PrefixableUnit<std::remove_const_t<decltype(si::kilo<si::gram>)>>
|
||||
static_assert(!PrefixableUnit<std::remove_const_t<decltype(si::metre / si::second)>>);
|
||||
static_assert(!PrefixableUnit<std::remove_const_t<decltype(1 / si::second)>>);
|
||||
static_assert(!PrefixableUnit<std::remove_const_t<decltype(mag<10> * si::second)>>);
|
||||
static_assert(!PrefixableUnit<std::remove_const_t<decltype(square<si::metre>)>>);
|
||||
static_assert(!PrefixableUnit<std::remove_const_t<decltype(square(si::metre))>>);
|
||||
static_assert(!PrefixableUnit<std::remove_const_t<decltype(pow<2>(si::metre))>>);
|
||||
static_assert(!PrefixableUnit<struct si::standard_gravity_unit>);
|
||||
static_assert(!PrefixableUnit<scaled_unit<mag<10>, struct si::second>>);
|
||||
@ -221,7 +221,7 @@ static_assert(AssociatedUnit<std::remove_const_t<decltype(si::kilo<si::gram>)>>)
|
||||
static_assert(AssociatedUnit<std::remove_const_t<decltype(si::metre / si::second)>>);
|
||||
static_assert(AssociatedUnit<std::remove_const_t<decltype(1 / si::second)>>);
|
||||
static_assert(AssociatedUnit<std::remove_const_t<decltype(mag<10> * si::second)>>);
|
||||
static_assert(AssociatedUnit<std::remove_const_t<decltype(square<si::metre>)>>);
|
||||
static_assert(AssociatedUnit<std::remove_const_t<decltype(square(si::metre))>>);
|
||||
static_assert(AssociatedUnit<std::remove_const_t<decltype(pow<2>(si::metre))>>);
|
||||
static_assert(AssociatedUnit<struct si::standard_gravity_unit>);
|
||||
static_assert(AssociatedUnit<scaled_unit<mag<10>, struct si::second>>);
|
||||
|
@ -90,11 +90,11 @@ inline constexpr struct force : system_reference<force_{}, kilogram / second> {}
|
||||
|
||||
// derived named units
|
||||
inline constexpr struct radian_ : named_unit<"rad", metre / metre, kind_of<angular_measure>> {} radian;
|
||||
inline constexpr struct steradian_ : named_unit<"sr", square<metre> / square<metre>, kind_of<solid_angular_measure>> {} steradian;
|
||||
inline constexpr struct steradian_ : named_unit<"sr", square(metre) / square(metre), kind_of<solid_angular_measure>> {} steradian;
|
||||
inline constexpr struct hertz_ : named_unit<"Hz", 1 / second, kind_of<frequency>> {} hertz;
|
||||
inline constexpr struct becquerel_ : named_unit<"Bq", 1 / second, kind_of<activity>> {} becquerel;
|
||||
inline constexpr struct newton_ : named_unit<"N", kilogram * metre / square<second>> {} newton;
|
||||
inline constexpr struct pascal_ : named_unit<"Pa", newton / square<metre>> {} pascal;
|
||||
inline constexpr struct newton_ : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct pascal_ : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
inline constexpr struct joule_ : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt_ : named_unit<"W", joule / second> {} watt;
|
||||
|
||||
@ -108,8 +108,8 @@ inline constexpr struct bit_ : named_unit<"bit", one, kind_of<storage_capacity>>
|
||||
// Unit as a reference
|
||||
static_assert(is_of_type<42 * metre, quantity<metre, int>>);
|
||||
static_assert(quantity<metre, int>::quantity_spec == length);
|
||||
static_assert(is_of_type<42 * square<metre>, quantity<square<metre>, int>>);
|
||||
static_assert(quantity<square<metre>, int>::quantity_spec == pow<2>(length));
|
||||
static_assert(is_of_type<42 * square(metre), quantity<square(metre), int>>);
|
||||
static_assert(quantity<square(metre), int>::quantity_spec == pow<2>(length));
|
||||
static_assert(is_of_type<42 * (metre / second), quantity<metre / second, int>>);
|
||||
static_assert(quantity<metre / second, int>::quantity_spec == length / time);
|
||||
static_assert(is_of_type<42 * newton, quantity<newton, int>>);
|
||||
@ -201,8 +201,8 @@ static_assert(
|
||||
quantity<reference<derived_quantity_spec<length_, per<time_>>{}, derived_unit<kilometre_, per<hour_>>{}>{},
|
||||
long double>>);
|
||||
|
||||
static_assert(is_of_type<1. / 4 * area[square<metre>], decltype(1. * area[square<metre>] / 4)>);
|
||||
static_assert(1. / 4 * area[square<metre>] == 1. * area[square<metre>] / 4);
|
||||
static_assert(is_of_type<1. / 4 * area[square(metre)], decltype(1. * area[square(metre)] / 4)>);
|
||||
static_assert(1. / 4 * area[square(metre)] == 1. * area[square(metre)] / 4);
|
||||
|
||||
// Natural Units
|
||||
static_assert(is_of_type<42 * nu::time[nu::second], quantity<reference<time, nu::second>{}, int>>);
|
||||
|
@ -115,10 +115,10 @@ static_assert(unit_symbol(one) == "");
|
||||
static_assert(unit_symbol(percent) == "%");
|
||||
static_assert(unit_symbol(per_mille) == "‰");
|
||||
static_assert(unit_symbol(per_mille, {.encoding = ascii}) == "%o");
|
||||
static_assert(unit_symbol(square<metre>) == "m²");
|
||||
static_assert(unit_symbol(square<metre>, {.encoding = ascii}) == "m^2");
|
||||
static_assert(unit_symbol(cubic<metre>) == "m³");
|
||||
static_assert(unit_symbol(cubic<metre>, {.encoding = ascii}) == "m^3");
|
||||
static_assert(unit_symbol(square(metre)) == "m²");
|
||||
static_assert(unit_symbol(square(metre), {.encoding = ascii}) == "m^2");
|
||||
static_assert(unit_symbol(cubic(metre)) == "m³");
|
||||
static_assert(unit_symbol(cubic(metre), {.encoding = ascii}) == "m^3");
|
||||
static_assert(unit_symbol(kilo<metre> * metre) == "km m");
|
||||
static_assert(unit_symbol(kilo<metre> * metre, {.separator = dot}) == "km⋅m");
|
||||
static_assert(unit_symbol(metre / metre) == "");
|
||||
@ -130,29 +130,29 @@ static_assert(unit_symbol(metre / second, {.solidus = always}) == "m/s");
|
||||
static_assert(unit_symbol(metre / second, {.solidus = never}) == "m s⁻¹");
|
||||
static_assert(unit_symbol(metre / second, {.encoding = ascii, .solidus = never}) == "m s^-1");
|
||||
static_assert(unit_symbol(metre / second, {.solidus = never, .separator = dot}) == "m⋅s⁻¹");
|
||||
static_assert(unit_symbol(metre / square<second>) == "m/s²");
|
||||
static_assert(unit_symbol(metre / square<second>, {.encoding = ascii}) == "m/s^2");
|
||||
static_assert(unit_symbol(metre / square<second>, {.solidus = always}) == "m/s²");
|
||||
static_assert(unit_symbol(metre / square<second>, {.encoding = ascii, .solidus = always}) == "m/s^2");
|
||||
static_assert(unit_symbol(metre / square<second>, {.solidus = never}) == "m s⁻²");
|
||||
static_assert(unit_symbol(metre / square<second>, {.encoding = ascii, .solidus = never}) == "m s^-2");
|
||||
static_assert(unit_symbol(metre / square<second>, {.solidus = never, .separator = dot}) == "m⋅s⁻²");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>) == "kg m/s²");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.separator = dot}) == "kg⋅m/s²");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.encoding = ascii}) == "kg m/s^2");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.solidus = always}) == "kg m/s²");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.encoding = ascii, .solidus = always}) == "kg m/s^2");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.solidus = never}) == "kg m s⁻²");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.encoding = ascii, .solidus = never}) == "kg m s^-2");
|
||||
static_assert(unit_symbol(kilogram * metre / square<second>, {.solidus = never, .separator = dot}) == "kg⋅m⋅s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>) == "kg m⁻¹ s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.separator = dot}) == "kg⋅m⁻¹⋅s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.encoding = ascii}) == "kg m^-1 s^-2");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.solidus = always}) == "kg/(m s²)");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.encoding = ascii, .solidus = always}) == "kg/(m s^2)");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.solidus = never}) == "kg m⁻¹ s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.encoding = ascii, .solidus = never}) == "kg m^-1 s^-2");
|
||||
static_assert(unit_symbol(kilogram / metre / square<second>, {.solidus = never, .separator = dot}) == "kg⋅m⁻¹⋅s⁻²");
|
||||
static_assert(unit_symbol(metre / square(second)) == "m/s²");
|
||||
static_assert(unit_symbol(metre / square(second), {.encoding = ascii}) == "m/s^2");
|
||||
static_assert(unit_symbol(metre / square(second), {.solidus = always}) == "m/s²");
|
||||
static_assert(unit_symbol(metre / square(second), {.encoding = ascii, .solidus = always}) == "m/s^2");
|
||||
static_assert(unit_symbol(metre / square(second), {.solidus = never}) == "m s⁻²");
|
||||
static_assert(unit_symbol(metre / square(second), {.encoding = ascii, .solidus = never}) == "m s^-2");
|
||||
static_assert(unit_symbol(metre / square(second), {.solidus = never, .separator = dot}) == "m⋅s⁻²");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second)) == "kg m/s²");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.separator = dot}) == "kg⋅m/s²");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.encoding = ascii}) == "kg m/s^2");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.solidus = always}) == "kg m/s²");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.encoding = ascii, .solidus = always}) == "kg m/s^2");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.solidus = never}) == "kg m s⁻²");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.encoding = ascii, .solidus = never}) == "kg m s^-2");
|
||||
static_assert(unit_symbol(kilogram * metre / square(second), {.solidus = never, .separator = dot}) == "kg⋅m⋅s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second)) == "kg m⁻¹ s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.separator = dot}) == "kg⋅m⁻¹⋅s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.encoding = ascii}) == "kg m^-1 s^-2");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.solidus = always}) == "kg/(m s²)");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.encoding = ascii, .solidus = always}) == "kg/(m s^2)");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.solidus = never}) == "kg m⁻¹ s⁻²");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.encoding = ascii, .solidus = never}) == "kg m^-1 s^-2");
|
||||
static_assert(unit_symbol(kilogram / metre / square(second), {.solidus = never, .separator = dot}) == "kg⋅m⁻¹⋅s⁻²");
|
||||
static_assert(unit_symbol(pow<123>(metre)) == "m¹²³");
|
||||
static_assert(unit_symbol(pow<1, 2>(metre)) == "m^(1/2)");
|
||||
static_assert(unit_symbol(pow<3, 5>(metre)) == "m^(3/5)");
|
||||
|
@ -58,11 +58,11 @@ inline constexpr struct nu_second_ : named_unit<"s"> {} nu_second;
|
||||
|
||||
// derived named units
|
||||
inline constexpr struct radian_ : named_unit<"rad", metre / metre> {} radian;
|
||||
inline constexpr struct steradian_ : named_unit<"sr", square<metre> / square<metre>> {} steradian;
|
||||
inline constexpr struct steradian_ : named_unit<"sr", square(metre) / square(metre)> {} steradian;
|
||||
inline constexpr struct hertz_ : named_unit<"Hz", 1 / second> {} hertz;
|
||||
inline constexpr struct becquerel_ : named_unit<"Bq", 1 / second> {} becquerel;
|
||||
inline constexpr struct newton_ : named_unit<"N", kilogram * metre / square<second>> {} newton;
|
||||
inline constexpr struct pascal_ : named_unit<"Pa", newton / square<metre>> {} pascal;
|
||||
inline constexpr struct newton_ : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct pascal_ : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
inline constexpr struct joule_ : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt_ : named_unit<"W", joule / second> {} watt;
|
||||
inline constexpr struct degree_Celsius_ : named_unit<basic_symbol_text{"°C", "`C"}, kelvin> {} degree_Celsius;
|
||||
@ -72,9 +72,9 @@ inline constexpr struct hour_ : named_unit<"h", mag<60> * minute> {} hour;
|
||||
inline constexpr struct day_ : named_unit<"d", mag<24> * hour> {} day;
|
||||
inline constexpr struct astronomical_unit_ : named_unit<"au", mag<149'597'870'700> * metre> {} astronomical_unit;
|
||||
inline constexpr struct degree_ : named_unit<basic_symbol_text{"°", "deg"}, mag_pi / mag<180> * radian> {} degree;
|
||||
inline constexpr struct are_ : named_unit<"a", square<si::deca<metre>>> {} are;
|
||||
inline constexpr struct are_ : named_unit<"a", square(si::deca<metre>)> {} are;
|
||||
inline constexpr struct hectare_ : decltype(si::hecto<are>) {} hectare;
|
||||
inline constexpr struct litre_ : named_unit<"l", cubic<si::deci<metre>>> {} litre;
|
||||
inline constexpr struct litre_ : named_unit<"l", cubic(si::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;
|
||||
inline constexpr struct electronvolt_ : named_unit<"eV", mag<ratio{1'602'176'634, 1'000'000'000}> * mag_power<10, -19> * joule> {} electronvolt;
|
||||
@ -87,7 +87,7 @@ inline constexpr struct kilometre_ : decltype(si::kilo<metre>) {} kilometre;
|
||||
inline constexpr struct kilojoule_ : decltype(si::kilo<joule>) {} kilojoule;
|
||||
|
||||
// physical constant units
|
||||
inline constexpr struct standard_gravity_unit_ : constant_unit<"g", mag<ratio{980'665, 100'000}> * metre / square<second>> {} standard_gravity_unit;
|
||||
inline constexpr struct standard_gravity_unit_ : constant_unit<"g", mag<ratio{980'665, 100'000}> * metre / square(second)> {} standard_gravity_unit;
|
||||
inline constexpr struct speed_of_light_in_vacuum_unit_ : constant_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum_unit;
|
||||
|
||||
// clang-format on
|
||||
@ -101,8 +101,8 @@ static_assert(Unit<hertz_>);
|
||||
static_assert(Unit<newton_>);
|
||||
static_assert(Unit<minute_>);
|
||||
static_assert(Unit<decltype(si::kilo<gram>)>);
|
||||
static_assert(Unit<decltype(square<metre>)>);
|
||||
static_assert(Unit<decltype(cubic<metre>)>);
|
||||
static_assert(Unit<decltype(square(metre))>);
|
||||
static_assert(Unit<decltype(cubic(metre))>);
|
||||
static_assert(Unit<decltype(mag<60> * second)>);
|
||||
static_assert(Unit<decltype(second * second)>);
|
||||
static_assert(Unit<decltype(nu_second * nu_second)>);
|
||||
@ -110,19 +110,19 @@ static_assert(Unit<decltype(metre / second)>);
|
||||
static_assert(Unit<decltype(nu_second / nu_second)>);
|
||||
static_assert(Unit<kilometre_>);
|
||||
|
||||
static_assert(NamedUnit<metre_>);
|
||||
static_assert(NamedUnit<hertz_>);
|
||||
static_assert(NamedUnit<newton_>);
|
||||
static_assert(NamedUnit<minute_>);
|
||||
static_assert(NamedUnit<radian_>);
|
||||
static_assert(!NamedUnit<kilogram_>);
|
||||
static_assert(!NamedUnit<kilojoule_>);
|
||||
static_assert(!NamedUnit<hectare_>);
|
||||
static_assert(!NamedUnit<decltype(si::kilo<gram>)>);
|
||||
static_assert(!NamedUnit<decltype(square<metre>)>);
|
||||
static_assert(!NamedUnit<decltype(cubic<metre>)>);
|
||||
static_assert(!NamedUnit<decltype(mag<60> * second)>);
|
||||
static_assert(!NamedUnit<kilometre_>);
|
||||
static_assert(detail::NamedUnit<metre_>);
|
||||
static_assert(detail::NamedUnit<hertz_>);
|
||||
static_assert(detail::NamedUnit<newton_>);
|
||||
static_assert(detail::NamedUnit<minute_>);
|
||||
static_assert(detail::NamedUnit<radian_>);
|
||||
static_assert(!detail::NamedUnit<kilogram_>);
|
||||
static_assert(!detail::NamedUnit<kilojoule_>);
|
||||
static_assert(!detail::NamedUnit<hectare_>);
|
||||
static_assert(!detail::NamedUnit<decltype(si::kilo<gram>)>);
|
||||
static_assert(!detail::NamedUnit<decltype(square(metre))>);
|
||||
static_assert(!detail::NamedUnit<decltype(cubic(metre))>);
|
||||
static_assert(!detail::NamedUnit<decltype(mag<60> * second)>);
|
||||
static_assert(!detail::NamedUnit<kilometre_>);
|
||||
|
||||
// named unit
|
||||
static_assert(is_of_type<metre, metre_>);
|
||||
@ -195,9 +195,9 @@ static_assert(
|
||||
is_of_type<get_canonical_unit(standard_gravity_unit).reference_unit, derived_unit<metre_, per<power<second_, 2>>>>);
|
||||
static_assert(get_canonical_unit(standard_gravity_unit).mag == mag<ratio{980'665, 100'000}>);
|
||||
static_assert(convertible(standard_gravity_unit, standard_gravity_unit));
|
||||
static_assert(convertible(standard_gravity_unit, metre / square<second>));
|
||||
static_assert(convertible(standard_gravity_unit, metre / square(second)));
|
||||
static_assert(standard_gravity_unit == standard_gravity_unit);
|
||||
static_assert(standard_gravity_unit != metre / square<second>); // magnitude is different
|
||||
static_assert(standard_gravity_unit != metre / square(second)); // magnitude is different
|
||||
static_assert(standard_gravity_unit.symbol == "[g]");
|
||||
|
||||
// prefixed_unit
|
||||
@ -285,17 +285,17 @@ static_assert(is_of_type<1 / second * one, derived_unit<one_, per<second_>>>);
|
||||
|
||||
static_assert(is_of_type<metre * second, derived_unit<metre_, second_>>);
|
||||
static_assert(is_of_type<metre * metre, derived_unit<power<metre_, 2>>>);
|
||||
static_assert(is_of_type<square<metre>, derived_unit<power<metre_, 2>>>);
|
||||
static_assert(is_of_type<cubic<metre>, derived_unit<power<metre_, 3>>>);
|
||||
static_assert(is_of_type<square<metre> * metre, derived_unit<power<metre_, 3>>>);
|
||||
static_assert(is_of_type<metre * square<metre>, derived_unit<power<metre_, 3>>>);
|
||||
static_assert(is_of_type<square<metre> / metre, metre_>);
|
||||
static_assert(is_of_type<cubic<metre> / metre, derived_unit<power<metre_, 2>>>);
|
||||
static_assert(is_of_type<cubic<metre> / square<metre>, metre_>);
|
||||
static_assert(is_of_type<square(metre), derived_unit<power<metre_, 2>>>);
|
||||
static_assert(is_of_type<cubic(metre), derived_unit<power<metre_, 3>>>);
|
||||
static_assert(is_of_type<square(metre) * metre, derived_unit<power<metre_, 3>>>);
|
||||
static_assert(is_of_type<metre * square(metre), derived_unit<power<metre_, 3>>>);
|
||||
static_assert(is_of_type<square(metre) / metre, metre_>);
|
||||
static_assert(is_of_type<cubic(metre) / metre, derived_unit<power<metre_, 2>>>);
|
||||
static_assert(is_of_type<cubic(metre) / square(metre), metre_>);
|
||||
|
||||
static_assert(is_of_type<metre / second, derived_unit<metre_, per<second_>>>);
|
||||
static_assert(is_of_type<metre / square<second>, derived_unit<metre_, per<power<second_, 2>>>>);
|
||||
static_assert(is_of_type<metre / square<second> / second, derived_unit<metre_, per<power<second_, 3>>>>);
|
||||
static_assert(is_of_type<metre / square(second), derived_unit<metre_, per<power<second_, 2>>>>);
|
||||
static_assert(is_of_type<metre / square(second) / second, derived_unit<metre_, per<power<second_, 3>>>>);
|
||||
|
||||
static_assert(is_of_type<metre * metre * second, derived_unit<power<metre_, 2>, second_>>);
|
||||
static_assert(is_of_type<metre * second * metre, derived_unit<power<metre_, 2>, second_>>);
|
||||
@ -326,12 +326,12 @@ static_assert(is_of_type<1 / (1 / second), second_>);
|
||||
static_assert(is_of_type<one / (1 / second), second_>);
|
||||
|
||||
static_assert(is_of_type<1 / pascal, derived_unit<one_, per<pascal_>>>);
|
||||
static_assert(is_of_type<1 / gram * metre * square<second>, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<1 / (gram / (metre * square<second>)), derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<one*(metre* square<second> / gram), derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<one * metre * square<second> / gram, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<(metre * square<second> / gram) * one, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<metre * square<second> / gram * one, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<1 / gram * metre * square(second), derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<1 / (gram / (metre * square(second))), derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<one*(metre* square(second) / gram), derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<one * metre * square(second) / gram, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<(metre * square(second) / gram) * one, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
static_assert(is_of_type<metre * square(second) / gram * one, derived_unit<metre_, power<second_, 2>, per<gram_>>>);
|
||||
|
||||
static_assert(is_of_type<standard_gravity_unit * gram, derived_unit<standard_gravity_unit_, gram_>>);
|
||||
static_assert(is_of_type<gram * standard_gravity_unit, derived_unit<standard_gravity_unit_, gram_>>);
|
||||
@ -347,7 +347,7 @@ static_assert(std::is_same_v<decltype(1 / second * metre), decltype(metre / seco
|
||||
static_assert(std::is_same_v<decltype(metre * (1 / second)), decltype(metre / second)>);
|
||||
static_assert(std::is_same_v<decltype((metre / second) * (1 / second)), decltype(metre / second / second)>);
|
||||
static_assert(std::is_same_v<decltype((metre / second) * (1 / second)), decltype(metre / (second * second))>);
|
||||
static_assert(std::is_same_v<decltype((metre / second) * (1 / second)), decltype(metre / square<second>)>);
|
||||
static_assert(std::is_same_v<decltype((metre / second) * (1 / second)), decltype(metre / square(second))>);
|
||||
|
||||
|
||||
// derived unit normalization
|
||||
@ -474,11 +474,11 @@ static_assert(metre / metre == one);
|
||||
static_assert(hertz * second == one);
|
||||
|
||||
static_assert(hertz == 1 / second);
|
||||
static_assert(newton == kilogram * metre / square<second>);
|
||||
static_assert(joule == kilogram * square<metre> / square<second>);
|
||||
static_assert(newton == kilogram * metre / square(second));
|
||||
static_assert(joule == kilogram * square(metre) / square(second));
|
||||
static_assert(joule == newton * metre);
|
||||
static_assert(watt == joule / second);
|
||||
static_assert(watt == kilogram * square<metre> / cubic<second>);
|
||||
static_assert(watt == kilogram * square(metre) / cubic(second));
|
||||
|
||||
// power
|
||||
static_assert(is_same_v<decltype(pow<2>(metre)), decltype(metre * metre)>);
|
||||
|
@ -72,16 +72,16 @@ static_assert(isq::length(1 * survey1893::us_survey_mile) == isq::length(8 * sur
|
||||
static_assert(isq::length(1 * survey1893::league) == isq::length(3 * survey1893::us_survey_mile));
|
||||
|
||||
// Area
|
||||
// static_assert(isq::area(1 * square<survey1893::us_survey_foot>) == isq::area(144 * square<inch>));
|
||||
static_assert(isq::area(1 * square<survey1893::chain>) == isq::area(4356 * square<survey1893::us_survey_foot>));
|
||||
static_assert(isq::area(1 * acre) == isq::area(43560 * square<survey1893::us_survey_foot>));
|
||||
static_assert(isq::area(1 * section) == isq::area(1 * square<survey1893::us_survey_mile>));
|
||||
// static_assert(isq::area(1 * square(survey1893::us_survey_foot)) == isq::area(144 * square(inch)));
|
||||
static_assert(isq::area(1 * square(survey1893::chain)) == isq::area(4356 * square(survey1893::us_survey_foot)));
|
||||
static_assert(isq::area(1 * acre) == isq::area(43560 * square(survey1893::us_survey_foot)));
|
||||
static_assert(isq::area(1 * section) == isq::area(1 * square(survey1893::us_survey_mile)));
|
||||
|
||||
// Volume
|
||||
static_assert(isq::volume(1 * cubic<foot>) == isq::volume(1'728 * cubic<inch>));
|
||||
static_assert(isq::volume(1 * cubic<yard>) == isq::volume(27 * cubic<foot>));
|
||||
static_assert(isq::volume(1 * cubic(foot)) == isq::volume(1'728 * cubic(inch)));
|
||||
static_assert(isq::volume(1 * cubic(yard)) == isq::volume(27 * cubic(foot)));
|
||||
static_assert(isq::volume(1 * (acre * survey1893::us_survey_foot)) ==
|
||||
isq::volume(43'560 * cubic<survey1893::us_survey_foot>));
|
||||
isq::volume(43'560 * cubic(survey1893::us_survey_foot)));
|
||||
|
||||
// Fluid volume
|
||||
static_assert(isq::volume(1 * fl_dr) == isq::volume(60 * min));
|
||||
@ -104,7 +104,7 @@ static_assert(isq::volume(1 * dry_qt) == isq::volume(2 * dry_pt));
|
||||
static_assert(isq::volume(1 * dry_gal) == isq::volume(4 * dry_qt));
|
||||
static_assert(isq::volume(1 * pk) == isq::volume(2 * dry_gal));
|
||||
static_assert(isq::volume(1 * bu) == isq::volume(4 * pk));
|
||||
static_assert(isq::volume(1 * dry_bbl) == isq::volume(7056 * cubic<inch>));
|
||||
static_assert(isq::volume(1 * dry_bbl) == isq::volume(7056 * cubic(inch)));
|
||||
|
||||
// Mass
|
||||
static_assert(isq::mass(7'000 * gr) == isq::mass(1 * lb));
|
||||
|
Reference in New Issue
Block a user