diff --git a/src/core/include/mp-units/bits/quantity_spec_concepts.h b/src/core/include/mp-units/bits/quantity_spec_concepts.h index 27543dde..c74f565a 100644 --- a/src/core/include/mp-units/bits/quantity_spec_concepts.h +++ b/src/core/include/mp-units/bits/quantity_spec_concepts.h @@ -143,4 +143,17 @@ template concept QuantitySpec = detail::NamedQuantitySpec || detail::IntermediateDerivedQuantitySpec || detail::QuantityKindSpec; +template +[[nodiscard]] consteval QuantitySpec auto get_kind(Q q); + +namespace detail { + +template +concept DerivedFromQuantityKindSpecOf = + QuantitySpec> && QuantitySpec> && + get_kind(From) != get_kind(To) && + std::derived_from, std::remove_cvref_t>; + +} + } // namespace mp_units diff --git a/src/core/include/mp-units/bits/unit_concepts.h b/src/core/include/mp-units/bits/unit_concepts.h index 152ca819..bc4154ee 100644 --- a/src/core/include/mp-units/bits/unit_concepts.h +++ b/src/core/include/mp-units/bits/unit_concepts.h @@ -188,7 +188,6 @@ concept UnitOf = AssociatedUnit && QuantitySpec, - std::remove_const_t>); + !detail::DerivedFromQuantityKindSpecOf); } // namespace mp_units diff --git a/src/core/include/mp-units/quantity_spec.h b/src/core/include/mp-units/quantity_spec.h index 4412c099..c8386cdc 100644 --- a/src/core/include/mp-units/quantity_spec.h +++ b/src/core/include/mp-units/quantity_spec.h @@ -433,9 +433,6 @@ struct derived_quantity_spec : */ QUANTITY_SPEC(dimensionless, derived_quantity_spec<>{}); -template -[[nodiscard]] consteval QuantitySpec auto get_kind(Q q); - /** * @brief Quantity kind specifier * @@ -1331,10 +1328,7 @@ template else return exploded_kind_result( convertible_impl(from_kind, get_kind(explode(to_kind).quantity))); - } else if constexpr (get_kind(from) != get_kind(to) && - std::derived_from, - std::remove_cvref_t> && - get_kind(to) == to) + } else if constexpr (DerivedFromQuantityKindSpecOf && get_kind(to) == to) return yes; else if constexpr (NamedQuantitySpec && NamedQuantitySpec) { if constexpr (have_common_base(from, to)) { @@ -1461,11 +1455,9 @@ template using QQ2 = std::remove_const_t; if constexpr (is_same_v) return q1; - else if constexpr (get_kind(q1) != get_kind(q2) && std::derived_from, - std::remove_const_t>) + else if constexpr (detail::DerivedFromQuantityKindSpecOf) return remove_kind(q1); - else if constexpr (get_kind(q1) != get_kind(q2) && std::derived_from, - std::remove_const_t>) + else if constexpr (detail::DerivedFromQuantityKindSpecOf) return remove_kind(q2); else if constexpr ((detail::QuantityKindSpec && !detail::QuantityKindSpec) || (detail::IntermediateDerivedQuantitySpec && detail::NamedQuantitySpec &&