mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
refactor: SameQuantitySpec
concept removed and replaced with direct comparison
This commit is contained in:
@ -508,7 +508,7 @@ template<QuantitySpec Q>
|
||||
} // namespace detail
|
||||
|
||||
template<typename Q>
|
||||
requires(!detail::QuantityKindSpec<Q>) && detail::SameQuantitySpec<detail::get_kind_tree_root(Q{}), Q{}>
|
||||
requires(!detail::QuantityKindSpec<Q>) && (detail::get_kind_tree_root(Q{}) == Q{})
|
||||
#if MP_UNITS_API_NO_CRTP
|
||||
struct kind_of_<Q> final : Q::_base_type_ {
|
||||
#else
|
||||
|
@ -105,10 +105,6 @@ MP_UNITS_EXPORT template<QuantitySpec Q>
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<auto QS1, auto QS2>
|
||||
concept SameQuantitySpec = QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS1))> &&
|
||||
QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS2))> && (QS1 == QS2);
|
||||
|
||||
template<QuantitySpec Child, QuantitySpec Parent>
|
||||
[[nodiscard]] consteval bool is_child_of(Child ch, Parent p);
|
||||
|
||||
@ -118,7 +114,7 @@ concept ChildQuantitySpecOf = (is_child_of(Child, Parent));
|
||||
template<auto To, auto From>
|
||||
concept NestedQuantityKindSpecOf =
|
||||
QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(From))> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(To))> &&
|
||||
(!SameQuantitySpec<get_kind(From), get_kind(To)>) && ChildQuantitySpecOf<To, get_kind(From)._quantity_spec_>;
|
||||
(get_kind(From) != get_kind(To)) && ChildQuantitySpecOf<To, get_kind(From)._quantity_spec_>;
|
||||
|
||||
template<auto From, auto To>
|
||||
concept QuantitySpecConvertibleTo =
|
||||
|
@ -104,11 +104,11 @@ concept AssociatedUnit = Unit<U> && detail::has_associated_quantity(U{});
|
||||
* the provided quantity_spec type.
|
||||
*/
|
||||
MP_UNITS_EXPORT template<typename U, auto QS>
|
||||
concept UnitOf = AssociatedUnit<U> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS))> &&
|
||||
detail::QuantitySpecConvertibleTo<get_quantity_spec(U{}), QS> &&
|
||||
// the below is to make `dimensionless[radian]` invalid
|
||||
(detail::SameQuantitySpec<get_kind(QS), get_kind(get_quantity_spec(U{}))> ||
|
||||
!detail::NestedQuantityKindSpecOf<get_quantity_spec(U{}), QS>);
|
||||
concept UnitOf =
|
||||
AssociatedUnit<U> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS))> &&
|
||||
detail::QuantitySpecConvertibleTo<get_quantity_spec(U{}), QS> &&
|
||||
// the below is to make `dimensionless[radian]` invalid
|
||||
(get_kind(QS) == get_kind(get_quantity_spec(U{})) || !detail::NestedQuantityKindSpecOf<get_quantity_spec(U{}), QS>);
|
||||
|
||||
MP_UNITS_EXPORT template<Unit From, Unit To>
|
||||
[[nodiscard]] consteval bool convertible(From from, To to);
|
||||
|
Reference in New Issue
Block a user