fix value_cast with lvalue references to quantity_point

This commit is contained in:
Yves Delley
2024-05-10 23:08:46 +02:00
parent 8f8b908b3d
commit 14f658120e
2 changed files with 5 additions and 5 deletions

View File

@@ -107,7 +107,7 @@ template<Unit auto ToU, typename QP>
[[nodiscard]] constexpr QuantityPoint auto value_cast(QP&& qp) [[nodiscard]] constexpr QuantityPoint auto value_cast(QP&& qp)
{ {
return quantity_point{value_cast<ToU>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_), return quantity_point{value_cast<ToU>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_),
qp.point_origin}; std::remove_reference_t<QP>::point_origin};
} }
/** /**
@@ -124,10 +124,10 @@ template<Representation ToRep, typename QP>
requires QuantityPoint<std::remove_cvref_t<QP>> && requires QuantityPoint<std::remove_cvref_t<QP>> &&
RepresentationOf<ToRep, std::remove_reference_t<QP>::quantity_spec.character> && RepresentationOf<ToRep, std::remove_reference_t<QP>::quantity_spec.character> &&
std::constructible_from<ToRep, typename std::remove_reference_t<QP>::rep> std::constructible_from<ToRep, typename std::remove_reference_t<QP>::rep>
[[nodiscard]] constexpr quantity_point<std::remove_reference_t<QP>::reference, QP::point_origin, ToRep> value_cast( [[nodiscard]] constexpr quantity_point<std::remove_reference_t<QP>::reference, std::remove_reference_t<QP>::point_origin, ToRep> value_cast(
QP&& qp) QP&& qp)
{ {
return {value_cast<ToRep>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_), qp.point_origin}; return {value_cast<ToRep>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_), std::remove_reference_t<QP>::point_origin};
} }
/** /**
@@ -147,7 +147,7 @@ template<Unit auto ToU, Representation ToRep, typename QP>
[[nodiscard]] constexpr QuantityPoint auto value_cast(QP&& qp) [[nodiscard]] constexpr QuantityPoint auto value_cast(QP&& qp)
{ {
return quantity_point{value_cast<ToU, ToRep>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_), return quantity_point{value_cast<ToU, ToRep>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_),
qp.point_origin}; std::remove_reference_t<QP>::point_origin};
} }
} // namespace mp_units } // namespace mp_units