Skip to content

Commit

Permalink
refactor: explicit type of op/ for quantity and reference repla…
Browse files Browse the repository at this point in the history
…ced with constrained placeholder

This prevents additional instantiations of inversed quantities
  • Loading branch information
mpusz committed Nov 16, 2024
1 parent 1be54cb commit b00d061
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/include/mp-units/framework/quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ class quantity {
template<typename Value, std::derived_from<quantity> Q>
requires(!Quantity<Value>) &&
(!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};
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/mp-units/framework/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>>
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{})};
}
Expand Down

0 comments on commit b00d061

Please sign in to comment.