From d622ac974a62a67230b75a6333845041627d6a8b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 21 Nov 2024 20:27:30 +0100 Subject: [PATCH] refactor: `one_of` concept removed and replaced with `QSProperty` in `quantity_spec` --- src/core/include/mp-units/ext/type_traits.h | 3 -- .../mp-units/framework/quantity_spec.h | 30 ++++++++----------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/core/include/mp-units/ext/type_traits.h b/src/core/include/mp-units/ext/type_traits.h index 119a27c5..7534c8e0 100644 --- a/src/core/include/mp-units/ext/type_traits.h +++ b/src/core/include/mp-units/ext/type_traits.h @@ -125,9 +125,6 @@ template requires std::is_object_v using value_type_t = detail::value_type_impl::type; -template -concept one_of = (false || ... || std::same_as); - template [[nodiscard]] consteval bool contains() { diff --git a/src/core/include/mp-units/framework/quantity_spec.h b/src/core/include/mp-units/framework/quantity_spec.h index f27ef6ed..3ca46da2 100644 --- a/src/core/include/mp-units/framework/quantity_spec.h +++ b/src/core/include/mp-units/framework/quantity_spec.h @@ -180,6 +180,9 @@ struct quantity_spec_interface : quantity_spec_interface_base { #endif }; +template +concept QSProperty = (!QuantitySpec); + } // namespace detail MP_UNITS_EXPORT_BEGIN @@ -248,12 +251,10 @@ MP_UNITS_EXPORT_END * @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar */ #if MP_UNITS_API_NO_CRTP -template auto... Args> - requires(... && !QuantitySpec) +template struct quantity_spec : detail::quantity_spec_interface { #else -template auto... Args> - requires(... && !QuantitySpec) +template struct quantity_spec : detail::quantity_spec_interface { #endif using _base_type_ = quantity_spec; @@ -292,12 +293,10 @@ struct quantity_spec : detail::quantity_spec_interface * @tparam Args optionally a value of a `quantity_character` in case the base quantity should not be scalar */ #if MP_UNITS_API_NO_CRTP -template auto... Args> - requires(... && !QuantitySpec) +template struct quantity_spec : detail::quantity_spec_interface { #else -template auto... Args> - requires(... && !QuantitySpec) +template struct quantity_spec : detail::quantity_spec_interface { #endif using _base_type_ = quantity_spec; @@ -346,12 +345,10 @@ struct propagate_equation { * or `is_kind` in case the quantity starts a new hierarchy tree of a kind */ #if MP_UNITS_API_NO_CRTP -template auto... Args> - requires(... && !QuantitySpec) +template struct quantity_spec : detail::propagate_equation, detail::quantity_spec_interface { #else -template auto... Args> - requires(... && !QuantitySpec) +template struct quantity_spec : detail::propagate_equation, detail::quantity_spec_interface { #endif using _base_type_ = quantity_spec; @@ -407,14 +404,13 @@ struct quantity_spec : detail::propagate_equation, detail */ // clang-format on #if MP_UNITS_API_NO_CRTP -template auto... Args> - requires(detail::QuantitySpecExplicitlyConvertibleTo) && (... && !QuantitySpec) +template + requires(detail::QuantitySpecExplicitlyConvertibleTo) struct quantity_spec : detail::quantity_spec_interface { #else template auto... Args> - requires(detail::QuantitySpecExplicitlyConvertibleTo) && (... && !QuantitySpec) + detail::QSProperty auto... Args> + requires(detail::QuantitySpecExplicitlyConvertibleTo) struct quantity_spec : detail::quantity_spec_interface { #endif using _base_type_ = quantity_spec;