diff --git a/src/core/include/mp_units/bits/unit_concepts.h b/src/core/include/mp_units/bits/unit_concepts.h index 11f4f505..b39b41c4 100644 --- a/src/core/include/mp_units/bits/unit_concepts.h +++ b/src/core/include/mp_units/bits/unit_concepts.h @@ -140,8 +140,7 @@ template template [[nodiscard]] consteval bool has_associated_quantity(U) { - if constexpr (requires { U::quantity_spec; }) - return true; + if constexpr (requires { U::quantity_spec; }) return true; if constexpr (requires { U::reference_unit; }) return has_associated_quantity(U::reference_unit); else if constexpr (requires { typename U::_num_; }) @@ -158,4 +157,14 @@ template template concept AssociatedUnit = Unit && detail::has_associated_quantity(U{}); +/** + * @brief A concept matching all units associated with the provided quantity spec + * + * Satisfied by all units associated with the quantity_spec being the instantiation derived from + * the provided quantity_spec type. + */ +template +concept UnitOf = AssociatedUnit && QuantitySpec> && + implicitly_convertible(get_quantity_spec(U{}), V); + } // namespace mp_units