diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index b172727bf..f9625a9df 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -45,17 +45,22 @@ namespace mp_units { namespace detail { -template -concept IntegralConversionFactor = Unit && Unit && - decltype(is_integral(decltype(decltype(get_canonical_unit(UFrom))::mag / - decltype(get_canonical_unit(UTo))::mag){}))::value; +template +[[nodiscard]] consteval bool integral_conversion_factor(UFrom from, UTo to) +{ + if constexpr (is_same_v) + return true; + else + return decltype(is_integral( + decltype(decltype(get_canonical_unit(from))::mag / decltype(get_canonical_unit(to))::mag){}))::value; +} template concept QuantityConvertibleTo = Quantity && Quantity && implicitly_convertible(QFrom::quantity_spec, QTo::quantity_spec) && convertible(QFrom::unit, QTo::unit) && (treat_as_floating_point || - (!treat_as_floating_point && IntegralConversionFactor)) && + (!treat_as_floating_point && (integral_conversion_factor(QFrom::unit, QTo::unit)))) && // TODO consider providing constraints of sudo_cast here rather than testing if it can be called (its return type is // deduced thus the function is evaluated here and may emit truncating conversion or other warnings) requires(QFrom q) { detail::sudo_cast(q); };