mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
feat: Magnitude / Unit
operator added
This commit is contained in:
@@ -430,6 +430,15 @@ template<Unit Lhs, Unit Rhs>
|
||||
return detail::expr_multiply<derived_unit, struct one, detail::type_list_of_unit_less>(lhs, rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of multiplication with an inverse unit.
|
||||
*/
|
||||
template<Magnitude M, Unit U>
|
||||
[[nodiscard]] MP_UNITS_CONSTEVAL Unit auto operator/(M mag, const U u)
|
||||
{
|
||||
return mag * (1 / u);
|
||||
}
|
||||
|
||||
/**
|
||||
* `scaled_unit` specializations have priority in this operation. This means that the library framework
|
||||
* prevents passing it as an element to the `derived_unit`. In such case only the reference unit is passed
|
||||
|
@@ -41,7 +41,7 @@ inline constexpr struct elementary_charge :
|
||||
inline constexpr struct boltzmann_constant :
|
||||
named_unit<"k", mag<ratio{1'380'649, 1'000'000}> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant;
|
||||
inline constexpr struct avogadro_constant :
|
||||
named_unit<"N_A", mag<ratio{602'214'076, 100'000'000}> * mag_power<10, 23> * (1 / mole)> {} avogadro_constant;
|
||||
named_unit<"N_A", mag<ratio{602'214'076, 100'000'000}> * mag_power<10, 23> / mole> {} avogadro_constant;
|
||||
inline constexpr struct luminous_efficacy :
|
||||
named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
|
||||
// clang-format on
|
||||
|
Reference in New Issue
Block a user