5 Quantities and units library [quantities]

5.7 Quantity point [qty.pt]

5.7.4 Class template quantity_point [qty.pt.syn]

namespace mp_units { template<typename T> concept QuantityPoint = (is-derived-from-specialization-of<T, quantity_point>()); template<typename QP, auto V> concept QuantityPointOf = QuantityPoint<QP> && (QuantitySpecOf<decltype(auto(QP::quantity_spec)), V> || SameAbsolutePointOriginAs<decltype(auto(QP::absolute_point_origin)), V>); template<Reference auto R, PointOriginFor<get_quantity_spec(R)> auto PO = default_point_origin(R), RepresentationOf<get_quantity_spec(R)> Rep = double> class quantity_point { public: // member types and values static constexpr Reference auto reference = R; static constexpr QuantitySpec auto quantity_spec = get_quantity_spec(reference); static constexpr Dimension auto dimension = quantity_spec.dimension; static constexpr Unit auto unit = get_unit(reference); static constexpr PointOrigin auto absolute_point_origin = see below; static constexpr PointOrigin auto point_origin = PO; using rep = Rep; using quantity_type = quantity<reference, Rep>; quantity_type quantity-from-origin; // exposition only // [qty.pt.static], static member functions static constexpr quantity_point min() noexcept requires see below; static constexpr quantity_point max() noexcept requires see below; // [qty.pt.cons], constructors and assignment quantity_point() = default; quantity_point(const quantity_point&) = default; quantity_point(quantity_point&&) = default; ~quantity_point() = default; template<typename FwdQ, QuantityOf<quantity_spec> Q = std::remove_cvref_t<FwdQ>> requires std::constructible_from<quantity_type, FwdQ> && (point_origin == default_point_origin(R)) && (implicitly_convertible(Q::quantity_spec, quantity_spec)) constexpr explicit quantity_point(FwdQ&& q); template<typename FwdQ, QuantityOf<quantity_spec> Q = std::remove_cvref_t<FwdQ>> requires std::constructible_from<quantity_type, FwdQ> constexpr quantity_point(FwdQ&& q, decltype(PO)); template<typename FwdQ, PointOrigin PO2, QuantityOf<PO2::quantity-spec> Q = std::remove_cvref_t<FwdQ>> requires std::constructible_from<quantity_type, FwdQ> && SameAbsolutePointOriginAs<PO2, PO> constexpr quantity_point(FwdQ&& q, PO2); template<QuantityPointOf<absolute_point_origin> QP> requires std::constructible_from<quantity_type, typename QP::quantity_type> constexpr explicit(!std::convertible_to<typename QP::quantity_type, quantity_type>) quantity_point(const QP& qp); template<QuantityPointLike QP> requires see below constexpr explicit(see below) quantity_point(const QP& qp); quantity_point& operator=(const quantity_point&) = default; quantity_point& operator=(quantity_point&&) = default; // [qty.pt.conv], conversions template<SameAbsolutePointOriginAs<absolute_point_origin> NewPO> constexpr QuantityPointOf<(NewPO{})> auto point_for(NewPO new_origin) const; template<UnitCompatibleWith<unit, quantity_spec> ToU> requires see below constexpr QuantityPointOf<quantity_spec> auto in(ToU) const; template<RepresentationOf<quantity_spec> ToRep> requires see below constexpr QuantityPointOf<quantity_spec> auto in() const; template<RepresentationOf<quantity_spec> ToRep, UnitCompatibleWith<unit, quantity_spec> ToU> requires see below constexpr QuantityPointOf<quantity_spec> auto in(ToU) const; template<UnitCompatibleWith<unit, quantity_spec> ToU> requires see below constexpr QuantityPointOf<quantity_spec> auto force_in(ToU) const; template<RepresentationOf<quantity_spec> ToRep> requires see below constexpr QuantityPointOf<quantity_spec> auto force_in() const; template<RepresentationOf<quantity_spec> ToRep, UnitCompatibleWith<unit, quantity_spec> ToU> requires see below constexpr QuantityPointOf<quantity_spec> auto force_in(ToU) const; // [qty.pt.obs], quantity value observers template<PointOrigin PO2> requires(PO2{} == point_origin) constexpr quantity_type& quantity_ref_from(PO2) & noexcept; template<PointOrigin PO2> requires(PO2{} == point_origin) constexpr const quantity_type& quantity_ref_from(PO2) const & noexcept; template<PointOrigin PO2> requires(PO2{} == point_origin) void quantity_ref_from(PO2) const && = delete; template<PointOrigin PO2> requires requires(const quantity_point qp) { qp - PO2{}; } constexpr Quantity auto quantity_from(PO2) const; template<QuantityPointOf<absolute_point_origin> QP> constexpr Quantity auto quantity_from(const QP&) const; constexpr Quantity auto quantity_from_zero() const; // [qty.pt.conv.ops], conversion operations template<typename QP_, QuantityPointLike QP = std::remove_cvref_t<QP_>> requires see below constexpr explicit(see below) operator QP_() const & noexcept(see below); template<typename QP_, QuantityPointLike QP = std::remove_cvref_t<QP_>> requires see below constexpr explicit(see below) operator QP_() && noexcept(see below); // [qty.pt.unary.ops], unary operations template<Mutable<quantity_point> QP> friend constexpr decltype(auto) operator++(QP&& qp) requires see below; template<Mutable<quantity_point> QP> friend constexpr decltype(auto) operator--(QP&& qp) requires see below; constexpr quantity_point operator++(int) requires see below; constexpr quantity_point operator--(int) requires see below; // [qty.pt.assign.ops], compound assignment operations template<Mutable<quantity_point> QP, auto R2, typename Rep2> requires see below friend constexpr decltype(auto) operator+=(QP&& qp, const quantity<R2, Rep2>& q); template<Mutable<quantity_point> QP, auto R2, typename Rep2> requires see below friend constexpr decltype(auto) operator-=(QP&& qp, const quantity<R2, Rep2>& q); // [qty.pt.arith.ops], arithmetic operations template<std::derived_from<quantity_point> QP, auto R2, typename Rep2> friend constexpr QuantityPoint auto operator+(const QP& qp, const quantity<R2, Rep2>& q) requires see below; template<std::derived_from<quantity_point> QP, auto R2, typename Rep2> friend constexpr QuantityPoint auto operator+(const quantity<R2, Rep2>& q, const QP& qp) requires see below; template<std::derived_from<quantity_point> QP, auto R2, typename Rep2> friend constexpr QuantityPoint auto operator-(const QP& qp, const quantity<R2, Rep2>& q) requires see below; template<std::derived_from<quantity_point> QP, QuantityPointOf<absolute_point_origin> QP2> friend constexpr Quantity auto operator-(const QP& lhs, const QP2& rhs) requires see below; template<std::derived_from<quantity_point> QP, PointOrigin PO2> requires see below friend constexpr Quantity auto operator-(const QP& qp, PO2 po); template<std::derived_from<quantity_point> QP, PointOrigin PO2> requires see below friend constexpr Quantity auto operator-(PO2 po, const QP& qp); // [qty.pt.cmp], comparison template<std::derived_from<quantity_point> QP, QuantityPointOf<absolute_point_origin> QP2> requires see below friend constexpr bool operator==(const QP& lhs, const QP2& rhs); template<std::derived_from<quantity_point> QP, QuantityPointOf<absolute_point_origin> QP2> requires see below friend constexpr auto operator<=>(const QP& lhs, const QP2& rhs); }; template<Quantity Q> explicit quantity_point(Q q) -> quantity_point<Q::reference, default_point_origin(Q::reference), typename Q::rep>; template<Quantity Q, PointOriginFor<Q::quantity_spec> PO> quantity_point(Q, PO) -> quantity_point<Q::reference, PO{}, typename Q::rep>; template<QuantityPointLike QP, typename Traits = quantity_point_like_traits<QP>> explicit(quantity_point_like_traits<QP>::explicit_import) quantity_point(QP) -> quantity_point<Traits::reference, Traits::point_origin, typename Traits::rep>; }
quantity_point<R, PO, Rep> is a structural type (N4971, [temp.param]) if Rep is a structural type.
The member absolute_point_origin is equal to PO if is-derived-from-specialization-of<decltype(PO), absolute_point_origin>() is true, and to PO.quantity-point.absolute_point_origin otherwise.