@@ -330,43 +330,44 @@ class quantity_point {
330330 }
331331
332332 // unit conversions
333- template <detail::UnitCompatibleWith<unit, quantity_spec> ToU>
334- requires detail::QuantityConvertibleTo<quantity_type, quantity<detail::make_reference(quantity_spec, ToU{}), Rep> >
333+ template <detail::WeakUnitOf< quantity_spec> ToU>
334+ requires detail::ValuePreservingScaling1Rep<unit, ToU{}, rep >
335335 [[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto in (ToU) const
336336 {
337337 return ::mp_units::quantity_point{quantity_ref_from (point_origin).in (ToU{}), point_origin};
338338 }
339339
340340 template <RepresentationOf<quantity_spec> ToRep>
341- requires detail::QuantityConvertibleTo<quantity_type, quantity<reference, ToRep> >
341+ requires detail::ValuePreservingConstruction<ToRep, rep >
342342 [[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto in () const
343343 {
344344 return ::mp_units::quantity_point{quantity_ref_from (point_origin).template in <ToRep>(), point_origin};
345345 }
346346
347- template <RepresentationOf<quantity_spec> ToRep, detail::UnitCompatibleWith<unit, quantity_spec> ToU>
348- requires detail::QuantityConvertibleTo<quantity_type, quantity<detail::make_reference(quantity_spec, ToU{}), ToRep>>
347+ template <RepresentationOf<quantity_spec> ToRep, detail::WeakUnitOf<quantity_spec> ToU>
348+ requires detail::ValuePreservingConstruction<ToRep, rep> &&
349+ detail::ValuePreservingScaling2Reps<unit, rep, ToU{}, ToRep>
349350 [[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto in (ToU) const
350351 {
351352 return ::mp_units::quantity_point{quantity_ref_from (point_origin).template in <ToRep>(ToU{}), point_origin};
352353 }
353354
354- template <detail::UnitCompatibleWith<unit, quantity_spec> ToU>
355- requires requires ( const quantity_type q) { value_cast< ToU{}>(q); }
355+ template <detail::WeakUnitOf< quantity_spec> ToU>
356+ requires detail::SaneScaling<unit, ToU{}, rep>
356357 [[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto force_in (ToU) const
357358 {
358359 return ::mp_units::quantity_point{quantity_ref_from (point_origin).force_in (ToU{}), point_origin};
359360 }
360361
361362 template <RepresentationOf<quantity_spec> ToRep>
362- requires requires ( const quantity_type q) { value_cast <ToRep>(q); }
363+ requires std::constructible_from <ToRep, rep>
363364 [[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto force_in () const
364365 {
365366 return ::mp_units::quantity_point{quantity_ref_from (point_origin).template force_in <ToRep>(), point_origin};
366367 }
367368
368- template <RepresentationOf<quantity_spec> ToRep, detail::UnitCompatibleWith<unit, quantity_spec> ToU>
369- requires requires ( const quantity_type q) { value_cast< ToU{}, ToRep>(q); }
369+ template <RepresentationOf<quantity_spec> ToRep, detail::WeakUnitOf< quantity_spec> ToU>
370+ requires std::constructible_from<ToRep, rep> && detail::SaneScaling<unit, ToU{}, rep>
370371 [[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto force_in (ToU) const
371372 {
372373 return ::mp_units::quantity_point{quantity_ref_from (point_origin).template force_in <ToRep>(ToU{}), point_origin};
@@ -440,45 +441,41 @@ class quantity_point {
440441
441442 // compound assignment operators
442443 template <detail::Mutable<quantity_point> QP, auto R2, typename Rep2>
443- requires detail::QuantityConvertibleTo<quantity<R2, Rep2>, quantity_type> &&
444- requires (const quantity_type q) { quantity_from_origin_is_an_implementation_detail_ += q; }
444+ requires (implicitly_convertible(get_quantity_spec(R2), quantity_spec)) &&
445+ detail::ValuePreservingScaling2Reps<get_unit(R2), Rep2, unit, rep> &&
446+ requires (const quantity_type q) { quantity_from_origin_is_an_implementation_detail_ += q; }
445447 friend constexpr decltype (auto ) operator+=(QP&& qp, const quantity<R2, Rep2>& q)
446448 {
447449 qp.quantity_from_origin_is_an_implementation_detail_ += q;
448450 return std::forward<QP>(qp);
449451 }
450452
451453 template <detail::Mutable<quantity_point> QP, auto R2, typename Rep2>
452- requires detail::QuantityConvertibleTo<quantity<R2, Rep2>, quantity_type> &&
453- requires (const quantity_type q) { quantity_from_origin_is_an_implementation_detail_ -= q; }
454+ requires (implicitly_convertible(get_quantity_spec(R2), quantity_spec)) &&
455+ detail::ValuePreservingScaling2Reps<get_unit(R2), Rep2, unit, rep> &&
456+ requires (const quantity_type q) { quantity_from_origin_is_an_implementation_detail_ -= q; }
454457 friend constexpr decltype (auto ) operator-=(QP&& qp, const quantity<R2, Rep2>& q)
455458 {
456459 qp.quantity_from_origin_is_an_implementation_detail_ -= q;
457460 return std::forward<QP>(qp);
458461 }
459462
460463 // binary operators on quantity points
461- template <std::derived_from<quantity_point> QP, auto R2, typename Rep2>
462- // TODO simplify when gcc catches up
463- requires ReferenceOf<MP_UNITS_REMOVE_CONST(decltype (R2)), PO._quantity_spec_>
464+ template <std::derived_from<quantity_point> QP, ReferenceOf<PO._quantity_spec_> auto R2, typename Rep2>
464465 [[nodiscard]] friend constexpr QuantityPoint auto operator +(const QP& qp, const quantity<R2, Rep2>& q)
465466 requires requires { qp.quantity_ref_from (PO) + q; }
466467 {
467468 return detail::make_quantity_point (qp.quantity_ref_from (PO) + q, PO);
468469 }
469470
470- template <auto R1, typename Rep1, std::derived_from<quantity_point> QP>
471- // TODO simplify when gcc catches up
472- requires ReferenceOf<MP_UNITS_REMOVE_CONST(decltype (R1)), PO._quantity_spec_>
471+ template <ReferenceOf<PO._quantity_spec_> auto R1, typename Rep1, std::derived_from<quantity_point> QP>
473472 [[nodiscard]] friend constexpr QuantityPoint auto operator +(const quantity<R1, Rep1>& q, const QP& qp)
474473 requires requires { q + qp.quantity_ref_from (PO); }
475474 {
476475 return qp + q;
477476 }
478477
479- template <std::derived_from<quantity_point> QP, auto R2, typename Rep2>
480- // TODO simplify when gcc catches up
481- requires ReferenceOf<MP_UNITS_REMOVE_CONST(decltype (R2)), PO._quantity_spec_>
478+ template <std::derived_from<quantity_point> QP, ReferenceOf<PO._quantity_spec_> auto R2, typename Rep2>
482479 [[nodiscard]] friend constexpr QuantityPoint auto operator -(const QP& qp, const quantity<R2, Rep2>& q)
483480 requires requires { qp.quantity_ref_from (PO) - q; }
484481 {
0 commit comments