diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index d2acd5f6..7e404ce1 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -59,12 +59,15 @@ template template concept IsFloatingPoint = treat_as_floating_point; +template +concept ValuePreservingTo = + IsFloatingPoint || (!IsFloatingPoint && (integral_conversion_factor(FromUnit, ToUnit))); + template concept QuantityConvertibleTo = - Quantity && Quantity && detail::QuantitySpecConvertibleTo && - detail::UnitConvertibleTo && - (IsFloatingPoint || - (!IsFloatingPoint && (integral_conversion_factor(QFrom::unit, QTo::unit)))) && + Quantity && Quantity && QuantitySpecConvertibleTo && + UnitConvertibleTo && + ValuePreservingTo && // 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); };