From f74da4335b264beadb2f3cd937ba84abc6f9cb66 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 13 Sep 2023 18:28:49 +0200 Subject: [PATCH] refactor: `quantity_point::q_` renamed to `quantity_from_origin_` --- src/core/include/mp-units/quantity_point.h | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index 99db2d97..1972ea30 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -82,7 +82,7 @@ public: using rep = Rep; using quantity_type = quantity; - quantity_type q_; // needs to be public for a structural type + quantity_type quantity_from_origin_; // needs to be public for a structural type // static member functions [[nodiscard]] static constexpr quantity_point zero() noexcept @@ -112,7 +112,7 @@ public: requires std::constructible_from // TODO add perfect forwarding constexpr explicit(!std::convertible_to) quantity_point(const QP& qp) : - q_([&] { + quantity_from_origin_([&] { if constexpr (is_same_v, std::remove_const_t>) return qp.quantity_ref_from(point_origin); @@ -128,7 +128,8 @@ public: std::convertible_to< quantity::reference, typename quantity_point_like_traits::rep>, quantity_type> - constexpr explicit quantity_point(const QP& qp) : q_(quantity_point_like_traits::quantity_from_origin(qp)) + constexpr explicit quantity_point(const QP& qp) : + quantity_from_origin_(quantity_point_like_traits::quantity_from_origin(qp)) { } @@ -149,28 +150,28 @@ public: template> PO2> [[nodiscard]] constexpr auto&& quantity_ref_from(this Self&& self, PO2) noexcept { - return std::forward(self).q_; + return std::forward(self).quantity_from_origin_; } #else template> PO2> [[nodiscard]] constexpr quantity_type& quantity_ref_from(PO2) & noexcept { - return q_; + return quantity_from_origin_; } template> PO2> [[nodiscard]] constexpr const quantity_type& quantity_ref_from(PO2) const& noexcept { - return q_; + return quantity_from_origin_; } template> PO2> [[nodiscard]] constexpr quantity_type&& quantity_ref_from(PO2) && noexcept { - return std::move(q_); + return std::move(quantity_from_origin_); } template> PO2> [[nodiscard]] constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept { - return std::move(q_); + return std::move(quantity_from_origin_); } #endif @@ -190,43 +191,43 @@ public: // member unary operators constexpr quantity_point& operator++() - requires requires { ++q_; } + requires requires { ++quantity_from_origin_; } { - ++q_; + ++quantity_from_origin_; return *this; } [[nodiscard]] constexpr quantity_point operator++(int) - requires requires { q_++; } + requires requires { quantity_from_origin_++; } { - return quantity_point(q_++); + return quantity_point(quantity_from_origin_++); } constexpr quantity_point& operator--() - requires requires { --q_; } + requires requires { --quantity_from_origin_; } { - --q_; + --quantity_from_origin_; return *this; } [[nodiscard]] constexpr quantity_point operator--(int) - requires requires { q_--; } + requires requires { quantity_from_origin_--; } { - return quantity_point(q_--); + return quantity_point(quantity_from_origin_--); } // compound assignment operators constexpr quantity_point& operator+=(const quantity_type& q) - requires requires { q_ += q; } + requires requires { quantity_from_origin_ += q; } { - q_ += q; + quantity_from_origin_ += q; return *this; } constexpr quantity_point& operator-=(const quantity_type& q) - requires requires { q_ -= q; } + requires requires { quantity_from_origin_ -= q; } { - q_ -= q; + quantity_from_origin_ -= q; return *this; } @@ -242,7 +243,7 @@ private: template requires std::constructible_from && ReferenceOf, PO.quantity_spec> - constexpr explicit quantity_point(Q&& q) : q_(std::forward(q)) + constexpr explicit quantity_point(Q&& q) : quantity_from_origin_(std::forward(q)) { } };