xo-unit: + Dimensionless/Quantity

This commit is contained in:
Roland Conybeare 2024-04-24 11:35:10 -04:00
commit 5fd8269dcc

View file

@ -242,8 +242,7 @@ namespace xo {
return Quantity::divide(x, y);
}
/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
/** note: doesn not require unit scaling, so constexpr with c++23 **/
template <typename Quantity, typename Dimensionless>
requires quantity2_concept<Quantity> && std::is_arithmetic_v<Dimensionless>
constexpr auto
@ -252,6 +251,15 @@ namespace xo {
return x.divide_by(y);
}
/** note: doesn not require unit scaling, so constexpr with c++23 **/
template <typename Dimensionless, typename Quantity>
requires std::is_arithmetic_v<Dimensionless> && quantity2_concept<Quantity>
constexpr auto
operator/ (Dimensionless x, const Quantity & y)
{
return y.divide_into(x);
}
/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
template <typename Quantity, typename Quantity2>