Skip to content

Commit

Permalink
fix constexpr and format
Browse files Browse the repository at this point in the history
  • Loading branch information
burnpanck committed May 10, 2024
1 parent d837107 commit d03f9c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/core/include/mp-units/framework/quantity_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ template<QuantitySpec auto ToQS, typename Q>
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, std::remove_reference_t<Q>::unit)};
}

/**
Expand All @@ -81,7 +82,7 @@ template<QuantitySpec auto ToQS, typename QP>
[[nodiscard]] constexpr QuantityPoint auto quantity_cast(QP&& qp)
{
return QP{quantity_cast<ToQS>(std::forward<QP>(qp).quantity_from_origin_is_an_implementation_detail_),
qp.point_origin};
std::remove_reference_t<QP>::point_origin};
}

} // namespace mp_units
3 changes: 2 additions & 1 deletion test/static/quantity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ static_assert(is_of_type<quantity_cast<isq::distance>(isq::length(1 * m)), quant
static_assert(is_of_type<quantity_cast<kind_of<isq::length>>(isq::length(1 * m)), quantity<si::metre, int>>);
static_assert(is_of_type<quantity_cast<kind_of<isq::length>>(isq::distance(1 * m)), quantity<si::metre, int>>);
// lvalue references in quantity_cast
inline constexpr quantity<isq::distance[m], int> to_distance(quantity<m,int> arg){
inline constexpr quantity<isq::distance[m], int> to_distance(quantity<m, int> arg)
{
return quantity_cast<isq::distance>(arg);
}

Expand Down

0 comments on commit d03f9c1

Please sign in to comment.