From 9d05e31af787a0f2df7e7aa59727960ea88787fa Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 2 Nov 2024 13:45:42 +0100 Subject: [PATCH 1/2] refactor: `point_origin_interface::op-` cleanup --- src/core/include/mp-units/framework/quantity_point.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity_point.h b/src/core/include/mp-units/framework/quantity_point.h index 920abcabe..4fa468568 100644 --- a/src/core/include/mp-units/framework/quantity_point.h +++ b/src/core/include/mp-units/framework/quantity_point.h @@ -81,9 +81,9 @@ struct point_origin_interface { [[nodiscard]] friend constexpr Quantity auto operator-(PO1 po1, PO2 po2) { if constexpr (is_derived_from_specialization_of_v) { - return -(po2.quantity_point - po2.quantity_point.absolute_point_origin); + return po1 - po2.quantity_point; } else if constexpr (is_derived_from_specialization_of_v) { - return po1.quantity_point - po1.quantity_point.absolute_point_origin; + return po1.quantity_point - po2; } else { return po1.quantity_point - po2.quantity_point; } From 80a4d6bc80762ca227da70be15a4748b45f18c6e Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 2 Nov 2024 13:56:49 +0100 Subject: [PATCH 2/2] refactor: `QuantityLikeImpl` refactored to conform to API Reference by @JohelEGP --- src/core/include/mp-units/framework/quantity_concepts.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity_concepts.h b/src/core/include/mp-units/framework/quantity_concepts.h index 5f08235d6..15cdc260b 100644 --- a/src/core/include/mp-units/framework/quantity_concepts.h +++ b/src/core/include/mp-units/framework/quantity_concepts.h @@ -59,8 +59,10 @@ template typename Traits> concept QuantityLikeImpl = requires(const T& qty, const Traits::rep& num) { { Traits::to_numerical_value(qty) } -> std::same_as::rep>; { Traits::from_numerical_value(num) } -> std::same_as; - { Traits::explicit_import } -> std::convertible_to; - { Traits::explicit_export } -> std::convertible_to; + requires std::same_as::explicit_import), const bool>; + requires std::same_as::explicit_export), const bool>; + typename std::bool_constant::explicit_import>; + typename std::bool_constant::explicit_export>; }; } // namespace detail