Skip to content

Commit

Permalink
fix quantity_cast to accept lvalue references
Browse files Browse the repository at this point in the history
  • Loading branch information
burnpanck committed May 10, 2024
1 parent b119abe commit d837107
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/include/mp-units/framework/quantity_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ namespace mp_units {
* @tparam ToQS a quantity specification to use for a target quantity
*/
template<QuantitySpec auto ToQS, typename Q>
requires Quantity<std::remove_cvref_t<Q>> && (castable(Q::quantity_spec, ToQS))
requires Quantity<std::remove_cvref_t<Q>> && (castable(std::remove_reference_t<Q>::quantity_spec, ToQS))
[[nodiscard]] constexpr Quantity auto quantity_cast(Q&& q)
{
return quantity{std::forward<Q>(q).numerical_value_is_an_implementation_detail_, make_reference(ToQS, Q::unit)};
return quantity{std::forward<Q>(q).numerical_value_is_an_implementation_detail_, make_reference(ToQS, q.unit)};
}

/**
Expand All @@ -77,7 +77,7 @@ template<QuantitySpec auto ToQS, typename Q>
* @tparam ToQS a quantity specification to use for a target quantity point
*/
template<QuantitySpec auto ToQS, typename QP>
requires QuantityPoint<std::remove_cvref_t<QP>> && (castable(QP::quantity_spec, ToQS))
requires QuantityPoint<std::remove_cvref_t<QP>> && (castable(std::remove_reference_t<QP>::quantity_spec, ToQS))
[[nodiscard]] constexpr QuantityPoint auto quantity_cast(QP&& qp)
{
return QP{quantity_cast<ToQS>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_),
Expand Down

0 comments on commit d837107

Please sign in to comment.