From d03f9c17a340532536a5207ecb4f41226716eef0 Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Fri, 10 May 2024 20:15:15 +0200 Subject: [PATCH] fix constexpr and format --- src/core/include/mp-units/framework/quantity_cast.h | 5 +++-- test/static/quantity_test.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity_cast.h b/src/core/include/mp-units/framework/quantity_cast.h index 38e8aaf77..53b14815a 100644 --- a/src/core/include/mp-units/framework/quantity_cast.h +++ b/src/core/include/mp-units/framework/quantity_cast.h @@ -56,7 +56,8 @@ template 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)}; } /** @@ -81,7 +82,7 @@ template [[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 30a742823..b81113682 100644 --- a/test/static/quantity_test.cpp +++ b/test/static/quantity_test.cpp @@ -938,7 +938,8 @@ static_assert(is_of_type(isq::length(1 * m)), quant 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 -inline constexpr quantity to_distance(quantity arg){ +inline constexpr quantity to_distance(quantity arg) +{ return quantity_cast(arg); }