xo-unit: + arithmetic (*,/) for scaled_unit/natural_unit pairs
This commit is contained in:
parent
e72760925f
commit
ce113b557a
1 changed files with 44 additions and 0 deletions
|
|
@ -153,6 +153,28 @@ namespace xo {
|
|||
rr.outer_scale_sq_ * x_unit.outer_scale_sq_ * y_unit.outer_scale_sq_));
|
||||
}
|
||||
|
||||
template <typename Int,
|
||||
typename Int2x = detail::width2x_t<Int>>
|
||||
inline constexpr scaled_unit<Int>
|
||||
operator* (const scaled_unit<Int> & x_unit,
|
||||
const natural_unit<Int> & y_unit)
|
||||
{
|
||||
auto y_unit2 = detail::make_unit_rescale_result<Int>(y_unit);
|
||||
|
||||
return x_unit * y_unit2;
|
||||
}
|
||||
|
||||
template <typename Int,
|
||||
typename Int2x = detail::width2x_t<Int>>
|
||||
inline constexpr scaled_unit<Int>
|
||||
operator* (const natural_unit<Int> & x_unit,
|
||||
const scaled_unit<Int> & y_unit)
|
||||
{
|
||||
auto x_unit2 = detail::make_unit_rescale_result<Int>(x_unit);
|
||||
|
||||
return x_unit2 * y_unit;
|
||||
}
|
||||
|
||||
template <typename Int,
|
||||
typename Int2x = detail::width2x_t<Int>>
|
||||
inline constexpr scaled_unit<Int>
|
||||
|
|
@ -169,6 +191,28 @@ namespace xo {
|
|||
* ratio::ratio<Int2x>(y_unit.outer_scale_factor_)),
|
||||
rr.outer_scale_sq_ * x_unit.outer_scale_sq_ * y_unit.outer_scale_sq_));
|
||||
}
|
||||
|
||||
template <typename Int,
|
||||
typename Int2x = detail::width2x_t<Int>>
|
||||
inline constexpr scaled_unit<Int>
|
||||
operator/ (const scaled_unit<Int> & x_unit,
|
||||
const natural_unit<Int> & y_unit)
|
||||
{
|
||||
auto y_unit2 = detail::make_unit_rescale_result<Int>(y_unit);
|
||||
|
||||
return x_unit / y_unit2;
|
||||
}
|
||||
|
||||
template <typename Int,
|
||||
typename Int2x = detail::width2x_t<Int>>
|
||||
inline constexpr scaled_unit<Int>
|
||||
operator/ (const natural_unit<Int> & x_unit,
|
||||
const scaled_unit<Int> & y_unit)
|
||||
{
|
||||
auto x_unit2 = detail::make_unit_rescale_result<Int>(x_unit);
|
||||
|
||||
return x_unit2 / y_unit;
|
||||
}
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue