From 5ef499ac94f4b813c6a68bb7dccfb21666e44367 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 25 Oct 2024 22:49:06 +0200 Subject: [PATCH] feat: `DerivedQuantitySpecExpr` and `DerivedUnitExpr` removed --- .../mp-units/framework/quantity_spec.h | 7 +++++-- .../framework/quantity_spec_concepts.h | 21 +------------------ src/core/include/mp-units/framework/unit.h | 12 +++++------ .../mp-units/framework/unit_concepts.h | 18 +--------------- 4 files changed, 13 insertions(+), 45 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity_spec.h b/src/core/include/mp-units/framework/quantity_spec.h index 80a6d0ad..a3efa568 100644 --- a/src/core/include/mp-units/framework/quantity_spec.h +++ b/src/core/include/mp-units/framework/quantity_spec.h @@ -429,7 +429,10 @@ struct quantity_spec : detail::quantity_spec_interface +template +struct is_dimensionless : std::false_type {}; + +template struct derived_quantity_spec_impl : #if MP_UNITS_API_NO_CRTP detail::quantity_spec_interface, @@ -492,7 +495,7 @@ struct derived_quantity_spec_impl : * @note User should not instantiate this type! It is not exported from the C++ module. The library will * instantiate this type automatically based on the dimensional arithmetic equation provided by the user. */ -template +template struct derived_quantity_spec final : detail::derived_quantity_spec_impl {}; /** diff --git a/src/core/include/mp-units/framework/quantity_spec_concepts.h b/src/core/include/mp-units/framework/quantity_spec_concepts.h index 90792dd9..d801a7f9 100644 --- a/src/core/include/mp-units/framework/quantity_spec_concepts.h +++ b/src/core/include/mp-units/framework/quantity_spec_concepts.h @@ -76,28 +76,9 @@ template concept NamedQuantitySpec = QuantitySpec && is_derived_from_specialization_of_quantity_spec && (!QuantityKindSpec); -template -struct is_dimensionless : std::false_type {}; - -template -concept IsPowerOfQuantitySpec = is_specialization_of_power && - (NamedQuantitySpec || is_dimensionless::value); - - -template -constexpr bool is_per_of_quantity_specs = false; - -template -constexpr bool is_per_of_quantity_specs> = - (... && (NamedQuantitySpec || is_dimensionless::value || IsPowerOfQuantitySpec)); - -template -concept DerivedQuantitySpecExpr = detail::NamedQuantitySpec || detail::is_dimensionless::value || - detail::IsPowerOfQuantitySpec || detail::is_per_of_quantity_specs; - } // namespace detail -template +template struct derived_quantity_spec; namespace detail { diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index c8d99a9a..ad91c7af 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -67,7 +67,7 @@ struct scaled_unit_impl; template constexpr bool is_specialization_of_scaled_unit = false; -template +template struct derived_unit_impl; /** @@ -461,7 +461,7 @@ namespace detail { template struct is_one : std::false_type {}; -template +template struct derived_unit_impl : detail::unit_interface, detail::expr_fractions { using _base_type_ = derived_unit_impl; // exposition only }; @@ -513,7 +513,7 @@ struct derived_unit_impl : detail::unit_interface, detail::expr_fractions +template struct derived_unit final : detail::derived_unit_impl {}; /** @@ -831,13 +831,13 @@ constexpr auto unit_symbol_impl(Out out, const power&, const uni return copy_symbol_exponent(fmt.encoding, negative_power, out); } -template Out, DerivedUnitExpr... Us> +template Out, typename... Us> constexpr Out unit_symbol_impl(Out out, const type_list<>&, const unit_symbol_formatting&, bool) { return out; } -template Out, DerivedUnitExpr U, DerivedUnitExpr... Rest> +template Out, typename U, typename... Rest> constexpr Out unit_symbol_impl(Out out, const type_list&, const unit_symbol_formatting& fmt, bool negative_power) { @@ -845,7 +845,7 @@ constexpr Out unit_symbol_impl(Out out, const type_list&, const unit (print_separator(out, fmt), out = unit_symbol_impl(out, Rest{}, fmt, negative_power))); } -template Out, DerivedUnitExpr... Nums, DerivedUnitExpr... Dens> +template Out, typename... Nums, typename... Dens> constexpr Out unit_symbol_impl(Out out, const type_list& nums, const type_list& dens, const unit_symbol_formatting& fmt) { diff --git a/src/core/include/mp-units/framework/unit_concepts.h b/src/core/include/mp-units/framework/unit_concepts.h index b7379f4b..1ab5ec42 100644 --- a/src/core/include/mp-units/framework/unit_concepts.h +++ b/src/core/include/mp-units/framework/unit_concepts.h @@ -60,23 +60,7 @@ MP_UNITS_EXPORT struct one; MP_UNITS_EXPORT template concept PrefixableUnit = Unit && is_derived_from_specialization_of_v; -namespace detail { - -template -constexpr bool is_power_of_unit = requires { requires is_specialization_of_power && Unit; }; - -template -constexpr bool is_per_of_units = false; - -template -constexpr bool is_per_of_units> = (... && (Unit || is_power_of_unit)); - -template -concept DerivedUnitExpr = Unit || detail::is_power_of_unit || detail::is_per_of_units; - -} // namespace detail - -template +template struct derived_unit; MP_UNITS_EXPORT template