diff --git a/src/core/include/mp-units/framework/quantity_cast.h b/src/core/include/mp-units/framework/quantity_cast.h index 64d0154b..53b14815 100644 --- a/src/core/include/mp-units/framework/quantity_cast.h +++ b/src/core/include/mp-units/framework/quantity_cast.h @@ -53,10 +53,11 @@ namespace mp_units { * @tparam ToQS a quantity specification to use for a target quantity */ template - requires Quantity> && (castable(Q::quantity_spec, ToQS)) + requires Quantity> && (castable(std::remove_reference_t::quantity_spec, ToQS)) [[nodiscard]] constexpr Quantity auto quantity_cast(Q&& q) { - return quantity{std::forward(q).numerical_value_is_an_implementation_detail_, make_reference(ToQS, Q::unit)}; + return quantity{std::forward(q).numerical_value_is_an_implementation_detail_, + make_reference(ToQS, std::remove_reference_t::unit)}; } /** @@ -77,11 +78,11 @@ template * @tparam ToQS a quantity specification to use for a target quantity point */ template - requires QuantityPoint> && (castable(QP::quantity_spec, ToQS)) + requires QuantityPoint> && (castable(std::remove_reference_t::quantity_spec, ToQS)) [[nodiscard]] constexpr QuantityPoint auto quantity_cast(QP&& qp) { return QP{quantity_cast(std::forward(qp).quantity_from_origin_is_an_implementation_detail_), - qp.point_origin}; + std::remove_reference_t::point_origin}; } } // namespace mp_units diff --git a/test/static/quantity_test.cpp b/test/static/quantity_test.cpp index 4931ce74..69b653f7 100644 --- a/test/static/quantity_test.cpp +++ b/test/static/quantity_test.cpp @@ -937,7 +937,11 @@ static_assert(is_of_type(1 * m), quantity(isq::length(1 * m)), quantity>); static_assert(is_of_type>(isq::length(1 * m)), quantity>); static_assert(is_of_type>(isq::distance(1 * m)), quantity>); - +// lvalue references in quantity_cast +namespace lvalue_tests { +constexpr quantity lvalue_q = 1 * m; +static_assert(is_of_type(lvalue_q), quantity>); +} // namespace lvalue_tests // QuantityOf static_assert(QuantityOf, isq::length>);