mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
refactor: explicit type of op/
for quantity
and reference
replaced with constrained placeholder
This prevents additional instantiations of inversed quantities
This commit is contained in:
@ -584,7 +584,7 @@ public:
|
|||||||
template<typename Value, std::derived_from<quantity> Q>
|
template<typename Value, std::derived_from<quantity> Q>
|
||||||
requires(!Quantity<Value>) &&
|
requires(!Quantity<Value>) &&
|
||||||
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, const Value&, Rep>
|
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, const Value&, Rep>
|
||||||
[[nodiscard]] friend constexpr QuantityOf<inverse(quantity_spec)> auto operator/(const Value& val, const Q& q)
|
[[nodiscard]] friend constexpr Quantity auto operator/(const Value& val, const Q& q)
|
||||||
{
|
{
|
||||||
return ::mp_units::quantity{val / q.numerical_value_ref_in(unit), ::mp_units::one / R};
|
return ::mp_units::quantity{val / q.numerical_value_ref_in(unit), ::mp_units::one / R};
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ template<typename FwdRep, Reference R, RepresentationOf<get_quantity_spec(R{})>
|
|||||||
|
|
||||||
template<typename FwdRep, Reference R, RepresentationOf<get_quantity_spec(R{})> Rep = std::remove_cvref_t<FwdRep>>
|
template<typename FwdRep, Reference R, RepresentationOf<get_quantity_spec(R{})> Rep = std::remove_cvref_t<FwdRep>>
|
||||||
requires(!detail::OffsetUnit<decltype(get_unit(R{}))>)
|
requires(!detail::OffsetUnit<decltype(get_unit(R{}))>)
|
||||||
[[nodiscard]] constexpr quantity<inverse(R{}), Rep> operator/(FwdRep&& lhs, R)
|
[[nodiscard]] constexpr Quantity auto operator/(FwdRep&& lhs, R)
|
||||||
{
|
{
|
||||||
return quantity{std::forward<FwdRep>(lhs), inverse(R{})};
|
return quantity{std::forward<FwdRep>(lhs), inverse(R{})};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user