From 98d07b9ed1fbe292cce0ab484ba39f750b71ee50 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 17 Oct 2023 09:45:31 +0200 Subject: [PATCH] feat: :boom: `quantity_spec` and its kind should not compare equal --- example/kalman_filter/kalman.h | 6 +++--- src/core/include/mp-units/quantity_spec.h | 12 ------------ test/unit_test/static/reference_test.cpp | 18 +++++++++--------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index 50621236..dd925f55 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -92,7 +92,7 @@ constexpr mp_units::quantity kalman_gain // state update template K> - requires(Q::quantity_spec == QM::quantity_spec) + requires(implicitly_convertible(QM::quantity_spec, Q::quantity_spec)) constexpr state state_update(const state& predicted, QM measured, K gain) { return {get<0>(predicted) + gain * (measured - get<0>(predicted))}; @@ -100,7 +100,7 @@ constexpr state state_update(const state& predicted, QM measured, K gain) template K, mp_units::QuantityOf T> - requires(Q1::quantity_spec == QM::quantity_spec) + requires(implicitly_convertible(QM::quantity_spec, Q1::quantity_spec)) constexpr state state_update(const state& predicted, QM measured, std::array gain, T interval) { const auto q1 = get<0>(predicted) + get<0>(gain) * (measured - get<0>(predicted)); @@ -110,7 +110,7 @@ constexpr state state_update(const state& predicted, QM measured template K, mp_units::QuantityOf T> - requires(Q1::quantity_spec == QM::quantity_spec) + requires(implicitly_convertible(QM::quantity_spec, Q1::quantity_spec)) constexpr state state_update(const state& predicted, QM measured, std::array gain, T interval) { diff --git a/src/core/include/mp-units/quantity_spec.h b/src/core/include/mp-units/quantity_spec.h index e07c73f3..37de04d9 100644 --- a/src/core/include/mp-units/quantity_spec.h +++ b/src/core/include/mp-units/quantity_spec.h @@ -516,18 +516,6 @@ template return is_same_v; } -template -[[nodiscard]] consteval bool operator==(Lhs, Rhs) -{ - return is_same_v; -} - -template -[[nodiscard]] consteval bool operator==(Lhs, Rhs rhs) -{ - return is_same_v>; -} - [[nodiscard]] consteval QuantitySpec auto inverse(QuantitySpec auto q) { return dimensionless / q; } diff --git a/test/unit_test/static/reference_test.cpp b/test/unit_test/static/reference_test.cpp index 0f857fed..3aac7e59 100644 --- a/test/unit_test/static/reference_test.cpp +++ b/test/unit_test/static/reference_test.cpp @@ -105,15 +105,15 @@ static_assert(is_of_type<(kind_of / kind_of