From 046a83224e39763a047f25b4f83b4c7ca9337711 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 2 Nov 2024 22:45:36 +0100 Subject: [PATCH] refactor: `Forwarding` renamed to `Mutable` Resolves #215 --- .../include/mp-units/framework/quantity.h | 22 +++++++++---------- .../mp-units/framework/quantity_point.h | 8 +++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index 533c25182..8c265516c 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -112,8 +112,8 @@ concept SameValueAs = (equivalent(get_unit(R1), get_unit(R2))) && std::convertib template using quantity_like_type = quantity::reference, typename quantity_like_traits::rep>; -template -concept Forwarding = std::derived_from, U>; +template> +concept Mutable = (!std::is_const_v) && std::derived_from; } // namespace detail @@ -338,7 +338,7 @@ class quantity { return ::mp_units::quantity{-numerical_value_is_an_implementation_detail_, reference}; } - template Q> + template Q> friend constexpr decltype(auto) operator++(Q&& q) requires requires(rep v) { { ++v } -> std::same_as; @@ -356,7 +356,7 @@ class quantity { return ::mp_units::quantity{numerical_value_is_an_implementation_detail_++, reference}; } - template Q> + template Q> friend constexpr decltype(auto) operator--(Q&& q) requires requires(rep v) { { --v } -> std::same_as; @@ -375,7 +375,7 @@ class quantity { } // compound assignment operators - template Q, auto R2, typename Rep2> + template Q, auto R2, typename Rep2> requires detail::QuantityConvertibleTo, quantity> && requires(rep a, Rep2 b) { { a += b } -> std::same_as; } @@ -388,7 +388,7 @@ class quantity { return std::forward(lhs); } - template Q, auto R2, typename Rep2> + template Q, auto R2, typename Rep2> requires detail::QuantityConvertibleTo, quantity> && requires(rep a, Rep2 b) { { a -= b } -> std::same_as; } @@ -401,7 +401,7 @@ class quantity { return std::forward(lhs); } - template Q, auto R2, typename Rep2> + template Q, auto R2, typename Rep2> requires detail::QuantityConvertibleTo, quantity> && (!treat_as_floating_point) && requires(rep a, Rep2 b) { { a %= b } -> std::same_as; @@ -417,7 +417,7 @@ class quantity { return std::forward(lhs); } - template Q, detail::ValuePreservingTo Value> + template Q, detail::ValuePreservingTo Value> requires(!Quantity) && requires(rep a, Value b) { { a *= b } -> std::same_as; } @@ -429,7 +429,7 @@ class quantity { return std::forward(lhs); } - template Q1, QuantityOf Q2> + template Q1, QuantityOf Q2> requires(Q2::unit == ::mp_units::one) && detail::ValuePreservingTo && requires(rep a, Q2::rep b) { { a *= b } -> std::same_as; @@ -439,7 +439,7 @@ class quantity { return std::forward(lhs) *= rhs.numerical_value_is_an_implementation_detail_; } - template Q, detail::ValuePreservingTo Value> + template Q, detail::ValuePreservingTo Value> requires(!Quantity) && requires(rep a, Value b) { { a /= b } -> std::same_as; } @@ -452,7 +452,7 @@ class quantity { return std::forward(lhs); } - template Q1, QuantityOf Q2> + template Q1, QuantityOf Q2> requires(Q2::unit == ::mp_units::one) && detail::ValuePreservingTo && requires(rep a, Q2::rep b) { { a /= b } -> std::same_as; diff --git a/src/core/include/mp-units/framework/quantity_point.h b/src/core/include/mp-units/framework/quantity_point.h index 4fa468568..aadca9637 100644 --- a/src/core/include/mp-units/framework/quantity_point.h +++ b/src/core/include/mp-units/framework/quantity_point.h @@ -402,7 +402,7 @@ class quantity_point { } // member unary operators - template QP> + template QP> friend constexpr decltype(auto) operator++(QP&& qp) requires requires { ++qp.quantity_from_origin_is_an_implementation_detail_; } { @@ -416,7 +416,7 @@ class quantity_point { return {quantity_from_origin_is_an_implementation_detail_++, PO}; } - template QP> + template QP> friend constexpr decltype(auto) operator--(QP&& qp) requires requires { --qp.quantity_from_origin_is_an_implementation_detail_; } { @@ -431,7 +431,7 @@ class quantity_point { } // compound assignment operators - template QP> + template QP> requires requires(quantity_type q) { quantity_from_origin_is_an_implementation_detail_ += q; } friend constexpr decltype(auto) operator+=(QP&& qp, const quantity_type& q) { @@ -439,7 +439,7 @@ class quantity_point { return std::forward(qp); } - template QP> + template QP> requires requires(quantity_type q) { quantity_from_origin_is_an_implementation_detail_ -= q; } friend constexpr decltype(auto) operator-=(QP&& qp, const quantity_type& q) {