mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 10:57: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
|
} // namespace detail
|
||||||
|
|
||||||
template<typename Q>
|
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
|
#if MP_UNITS_API_NO_CRTP
|
||||||
struct kind_of_<Q> final : Q::_base_type_ {
|
struct kind_of_<Q> final : Q::_base_type_ {
|
||||||
#else
|
#else
|
||||||
|
@ -105,10 +105,6 @@ MP_UNITS_EXPORT template<QuantitySpec Q>
|
|||||||
|
|
||||||
namespace detail {
|
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>
|
template<QuantitySpec Child, QuantitySpec Parent>
|
||||||
[[nodiscard]] consteval bool is_child_of(Child ch, Parent p);
|
[[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>
|
template<auto To, auto From>
|
||||||
concept NestedQuantityKindSpecOf =
|
concept NestedQuantityKindSpecOf =
|
||||||
QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(From))> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(To))> &&
|
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>
|
template<auto From, auto To>
|
||||||
concept QuantitySpecConvertibleTo =
|
concept QuantitySpecConvertibleTo =
|
||||||
|
@ -104,11 +104,11 @@ concept AssociatedUnit = Unit<U> && detail::has_associated_quantity(U{});
|
|||||||
* the provided quantity_spec type.
|
* the provided quantity_spec type.
|
||||||
*/
|
*/
|
||||||
MP_UNITS_EXPORT template<typename U, auto QS>
|
MP_UNITS_EXPORT template<typename U, auto QS>
|
||||||
concept UnitOf = AssociatedUnit<U> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS))> &&
|
concept UnitOf =
|
||||||
detail::QuantitySpecConvertibleTo<get_quantity_spec(U{}), QS> &&
|
AssociatedUnit<U> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS))> &&
|
||||||
// the below is to make `dimensionless[radian]` invalid
|
detail::QuantitySpecConvertibleTo<get_quantity_spec(U{}), QS> &&
|
||||||
(detail::SameQuantitySpec<get_kind(QS), get_kind(get_quantity_spec(U{}))> ||
|
// the below is to make `dimensionless[radian]` invalid
|
||||||
!detail::NestedQuantityKindSpecOf<get_quantity_spec(U{}), QS>);
|
(get_kind(QS) == get_kind(get_quantity_spec(U{})) || !detail::NestedQuantityKindSpecOf<get_quantity_spec(U{}), QS>);
|
||||||
|
|
||||||
MP_UNITS_EXPORT template<Unit From, Unit To>
|
MP_UNITS_EXPORT template<Unit From, Unit To>
|
||||||
[[nodiscard]] consteval bool convertible(From from, To to);
|
[[nodiscard]] consteval bool convertible(From from, To to);
|
||||||
|
Reference in New Issue
Block a user