From 0d00be067aa9b65f2f897bbefe75d5b48901fa2b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 1 Oct 2024 21:37:31 +0200 Subject: [PATCH] refactor: `convertible(U1, U2)` implementation simplified --- src/core/include/mp-units/framework/unit.h | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index 6982f667..6194b845 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -130,17 +130,18 @@ using type_list_of_unit_less = expr_less; // Even though it is not exported, it is visible to the other module via ADL [[nodiscard]] consteval auto get_canonical_unit(Unit auto u) { return detail::get_canonical_unit_impl(u, u); } -namespace detail { - -template -[[nodiscard]] consteval bool have_same_canonical_reference_unit(U1 u1, U2 u2) +// convertible +template +[[nodiscard]] consteval bool convertible(From from, To to) { - if constexpr (is_same_v) + if constexpr (is_same_v) return true; else - return is_same_v; + return is_same_v; } +namespace detail { struct unit_interface { /** @@ -670,16 +671,6 @@ inline constexpr auto ppm = parts_per_million; // clang-format on -// convertible -template -[[nodiscard]] consteval bool convertible(From from, To to) -{ - if constexpr (is_same_v) - return true; - else - return detail::have_same_canonical_reference_unit(from, to); -} - // Common unit [[nodiscard]] consteval Unit auto get_common_unit(Unit auto u) { return u; }