diff --git a/src/core/include/mp_units/bits/quantity_cast.h b/src/core/include/mp_units/bits/quantity_cast.h index 70ae64af..11a19d39 100644 --- a/src/core/include/mp_units/bits/quantity_cast.h +++ b/src/core/include/mp_units/bits/quantity_cast.h @@ -55,11 +55,11 @@ class quantity; * * @tparam ToQS a quantity specification to use for a target quantity */ -template - requires(interconvertible(ToQS, get_quantity_spec(Q::reference))) +template + requires Quantity> && castable_to(get_quantity_spec(Q::reference), ToQS) [[nodiscard]] constexpr Quantity auto quantity_cast(Q&& q) { - constexpr reference r; + constexpr reference::unit> r; return std::forward(q).number() * r; } diff --git a/src/core/include/mp_units/bits/quantity_concepts.h b/src/core/include/mp_units/bits/quantity_concepts.h index 3dcc06bc..726aa87c 100644 --- a/src/core/include/mp_units/bits/quantity_concepts.h +++ b/src/core/include/mp_units/bits/quantity_concepts.h @@ -54,21 +54,9 @@ concept Quantity = requires(T* t) { detail::to_base_specialization_of_quantity(t * the provided dimension/reference type. */ template -concept QuantityOf = Quantity && ((Dimension> && Q::dimension == V) || - (QuantitySpec> && Q::quantity_spec == V) || - (Reference> && Q::reference == V)); - -/** - * @brief A concept matching all quantities with provided dimension or reference - * - * Satisfied by all quantities with a dimension/reference being the instantiation derived from - * the provided dimension/reference type. - */ -template -concept WeakQuantityOf = +concept QuantityOf = Quantity && ((Dimension> && Q::dimension == V) || - (QuantitySpec> && interconvertible(Q::quantity_spec, V)) || - (Reference> && Q::dimension == V.dimension && Q::unit == V.unit)); + (QuantitySpec> && implicitly_convertible_to(Q::quantity_spec, 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 fd18ea65..9dd36192 100644 --- a/src/core/include/mp_units/bits/quantity_point_concepts.h +++ b/src/core/include/mp_units/bits/quantity_point_concepts.h @@ -95,8 +95,7 @@ template concept QuantityPointOf = QuantityPoint && ((Dimension> && QP::dimension == V) || - (QuantitySpec> && QP::quantity_spec == V) || - (Reference> && QP::reference == V) || + (QuantitySpec> && implicitly_convertible_to(QP::quantity_spec, V)) || (PointOrigin> && std::same_as, std::remove_const_t>)); diff --git a/src/core/include/mp_units/bits/sudo_cast.h b/src/core/include/mp_units/bits/sudo_cast.h index 5e01a99b..2bc3bee0 100644 --- a/src/core/include/mp_units/bits/sudo_cast.h +++ b/src/core/include/mp_units/bits/sudo_cast.h @@ -43,7 +43,7 @@ namespace detail { * @tparam To a target quantity type to cast to */ template - requires(interconvertible(To::reference, R)) && + requires(castable_to(get_quantity_spec(R), To::quantity_spec)) && ((get_unit(R) == To::unit && std::constructible_from) || (get_unit(R) != To::unit)) // && scalable_with_)) // TODO how to constrain the second part here? diff --git a/src/core/include/mp_units/reference.h b/src/core/include/mp_units/reference.h index f316c126..84821698 100644 --- a/src/core/include/mp_units/reference.h +++ b/src/core/include/mp_units/reference.h @@ -122,19 +122,19 @@ struct reference { template [[nodiscard]] friend consteval bool convertible_to(reference, reference) { - return convertible_to(Q, Q2) && convertible_to(U, U2); + return implicitly_convertible_to(Q, Q2) && convertible_to(U, U2); } template [[nodiscard]] friend consteval bool convertible_to(reference, U2 u2) { - return convertible_to(Q, get_quantity_spec(u2)) && convertible_to(U, u2); + return implicitly_convertible_to(Q, get_quantity_spec(u2)) && convertible_to(U, u2); } template [[nodiscard]] friend consteval bool convertible_to(U1 u1, reference) { - return convertible_to(get_quantity_spec(u1), Q) && convertible_to(u1, U); + return implicitly_convertible_to(get_quantity_spec(u1), Q) && convertible_to(u1, U); } };