mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
refactor: make_quantity_point
introduced
This commit is contained in:
@ -51,6 +51,16 @@ template<PointOrigin PO>
|
||||
return is_specialization_of_zeroth_point_origin<PO>;
|
||||
}
|
||||
|
||||
template<typename FwdQ, PointOrigin PO,
|
||||
QuantityOf<detail::get_delta_quantity_spec(PO::_quantity_spec_)> Q = std::remove_cvref_t<FwdQ>>
|
||||
[[nodiscard]] constexpr QuantityPoint auto make_quantity_point(FwdQ&& q, PO po)
|
||||
{
|
||||
if constexpr (detail::is_zeroth_point_origin(PO{}))
|
||||
return quantity_point{std::forward<FwdQ>(q)};
|
||||
else
|
||||
return quantity_point{std::forward<FwdQ>(q), po};
|
||||
}
|
||||
|
||||
struct point_origin_interface {
|
||||
template<PointOrigin PO, typename FwdQ, QuantityOf<PO::_quantity_spec_> Q = std::remove_cvref_t<FwdQ>>
|
||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep>
|
||||
@ -456,10 +466,7 @@ public:
|
||||
[[nodiscard]] friend constexpr QuantityPoint auto operator+(const QP& qp, const quantity<R2, Rep2>& q)
|
||||
requires requires { qp.quantity_ref_from(PO) + q; }
|
||||
{
|
||||
if constexpr (detail::is_zeroth_point_origin(PO))
|
||||
return ::mp_units::quantity_point{qp.quantity_ref_from(PO) + q};
|
||||
else
|
||||
return ::mp_units::quantity_point{qp.quantity_ref_from(PO) + q, PO};
|
||||
return detail::make_quantity_point(qp.quantity_ref_from(PO) + q, PO);
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, std::derived_from<quantity_point> QP>
|
||||
@ -477,10 +484,7 @@ public:
|
||||
[[nodiscard]] friend constexpr QuantityPoint auto operator-(const QP& qp, const quantity<R2, Rep2>& q)
|
||||
requires requires { qp.quantity_ref_from(PO) - q; }
|
||||
{
|
||||
if constexpr (detail::is_zeroth_point_origin(PO))
|
||||
return ::mp_units::quantity_point{qp.quantity_ref_from(PO) - q};
|
||||
else
|
||||
return ::mp_units::quantity_point{qp.quantity_ref_from(PO) - q, PO};
|
||||
return detail::make_quantity_point(qp.quantity_ref_from(PO) - q, PO);
|
||||
}
|
||||
|
||||
template<std::derived_from<quantity_point> QP, QuantityPointOf<absolute_point_origin> QP2>
|
||||
|
Reference in New Issue
Block a user