diff --git a/src/core/include/mp_units/bits/quantity_concepts.h b/src/core/include/mp_units/bits/quantity_concepts.h index 64949d05..4539d85e 100644 --- a/src/core/include/mp_units/bits/quantity_concepts.h +++ b/src/core/include/mp_units/bits/quantity_concepts.h @@ -48,15 +48,13 @@ template concept Quantity = requires(T* t) { detail::to_base_specialization_of_quantity(t); }; /** - * @brief A concept matching all quantities with provided dimension or reference + * @brief A concept matching all quantities with provided dimension or quantity spec * - * Satisfied by all quantities with a dimension/reference being the instantiation derived from - * the provided dimension/reference type. + * Satisfied by all quantities with a dimension/quantity_spec being the instantiation derived from + * the provided dimension/quantity_spec type. */ template -concept QuantityOf = - Quantity && ((Dimension> && Q::dimension == V) || - (QuantitySpec> && implicitly_convertible(Q::quantity_spec, V))); +concept QuantityOf = Quantity && ReferenceOf, V>; /** * @brief A concept matching all external quantities like types diff --git a/src/core/include/mp_units/bits/quantity_point_concepts.h b/src/core/include/mp_units/bits/quantity_point_concepts.h index 85d2fc3f..3f20b08f 100644 --- a/src/core/include/mp_units/bits/quantity_point_concepts.h +++ b/src/core/include/mp_units/bits/quantity_point_concepts.h @@ -68,7 +68,8 @@ concept PointOrigin = QuantityPoint || detail::is_derived_from_specialization * Satisfied by all quantity point origins that are defined using a provided quantity specification. */ template -concept PointOriginFor = PointOrigin && QuantitySpec> && implicitly_convertible(Q, T::quantity_spec); +concept PointOriginFor = + PointOrigin && QuantitySpec> && implicitly_convertible(Q, T::quantity_spec); template auto PO, RepresentationOf Rep> @@ -86,16 +87,16 @@ inline constexpr bool is_quantity_point = true; } // namespace detail /** - * @brief A concept matching all quantity points with provided dimension or reference + * @brief A concept matching all quantity points with provided dimension or quantity spec * - * Satisfied by all quantity points with a dimension/reference being the instantiation derived from - * the provided dimension/reference type. + * Satisfied by all quantity points with a dimension/quantity_spec being the instantiation derived from + * the provided dimension/quantity_spec type, or quantity points having the origin with the same + * `absolute_point_origin`. */ template concept QuantityPointOf = QuantityPoint && - ((Dimension> && QP::dimension == V) || - (QuantitySpec> && implicitly_convertible(QP::quantity_spec, V)) || + (ReferenceOf, V> || (PointOrigin> && std::same_as, std::remove_const_t>)); diff --git a/src/core/include/mp_units/bits/reference_concepts.h b/src/core/include/mp_units/bits/reference_concepts.h index 669342ff..20d4bd96 100644 --- a/src/core/include/mp_units/bits/reference_concepts.h +++ b/src/core/include/mp_units/bits/reference_concepts.h @@ -48,4 +48,32 @@ inline constexpr bool is_specialization_of_reference> = true; template concept Reference = AssociatedUnit || detail::is_specialization_of_reference; +[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(AssociatedUnit auto u); + +template +[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(reference) +{ + return Q; +} + +[[nodiscard]] consteval Unit auto get_unit(AssociatedUnit auto u) { return u; } + +template +[[nodiscard]] consteval Unit auto get_unit(reference) +{ + return U; +} + +/** + * @brief A concept matching all references with provided dimension or quantity spec + * + * Satisfied by all references with a dimension/quantity_spec being the instantiation derived from + * the provided dimension/quantity_spec type. + */ +template +concept ReferenceOf = + Reference && + ((Dimension> && get_quantity_spec(T{}).dimension == V) || + (QuantitySpec> && implicitly_convertible(get_quantity_spec(T{}), V))); + } // namespace mp_units diff --git a/src/core/include/mp_units/reference.h b/src/core/include/mp_units/reference.h index 5573c686..400b855e 100644 --- a/src/core/include/mp_units/reference.h +++ b/src/core/include/mp_units/reference.h @@ -34,20 +34,6 @@ namespace mp_units { return detail::get_associated_quantity(u); } -template -[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(reference) -{ - return Q; -} - -[[nodiscard]] consteval Unit auto get_unit(AssociatedUnit auto u) { return u; } - -template -[[nodiscard]] consteval Unit auto get_unit(reference) -{ - return U; -} - /** * @brief Quantity reference type *