diff --git a/src/core/include/mp_units/quantity_spec.h b/src/core/include/mp_units/quantity_spec.h index f6c9e664..15a3ea54 100644 --- a/src/core/include/mp_units/quantity_spec.h +++ b/src/core/include/mp_units/quantity_spec.h @@ -1255,20 +1255,31 @@ template else if constexpr (QuantityKindSpec || QuantityKindSpec) { constexpr auto from_kind = get_kind(from); constexpr auto to_kind = get_kind(to); + constexpr auto exploded_kind_result = [](specs_convertible_result res) { + using enum specs_convertible_result; + return res == no ? no : yes; + }; if constexpr ((NamedQuantitySpec> && NamedQuantitySpec>) || get_complexity(from_kind) == get_complexity(to_kind)) return convertible_impl(from_kind, to_kind); else if constexpr (get_complexity(from_kind) > get_complexity(to_kind)) - return convertible_impl(get_kind(explode(from_kind).quantity), to_kind); + return exploded_kind_result( + convertible_impl(get_kind(explode(from_kind).quantity), to_kind)); else - return convertible_impl(from_kind, get_kind(explode(to_kind).quantity)); - } else if constexpr (NamedQuantitySpec && NamedQuantitySpec) { + 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) + return yes; + else if constexpr (NamedQuantitySpec && NamedQuantitySpec) { if constexpr (have_common_base(from, to)) { if (std::derived_from) return yes; else - return std::derived_from ? explicit_conversion : cast; + return std::derived_from ? explicit_conversion : (get_kind(from) == get_kind(to) ? cast : no); } else if constexpr (get_kind(from) != get_kind(to)) return no; else if constexpr (get_complexity(from) != get_complexity(to)) {