From 8423e507779a66bcc2332a52661b2f28f3c8141b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 8 Nov 2024 13:30:55 +0100 Subject: [PATCH] feat: `SymbolicArg` applied to expression templates --- .../mp-units/framework/expression_template.h | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/include/mp-units/framework/expression_template.h b/src/core/include/mp-units/framework/expression_template.h index 4514edd9..847f2d87 100644 --- a/src/core/include/mp-units/framework/expression_template.h +++ b/src/core/include/mp-units/framework/expression_template.h @@ -58,7 +58,7 @@ concept SymbolicConstant = * * @tparam Ts The list of types */ -template +template struct type_list {}; /** @@ -66,7 +66,7 @@ struct type_list {}; * * @note Can't be empty */ -template +template struct per {}; namespace detail { @@ -113,7 +113,7 @@ constexpr bool ratio_one = true; * * @note @p Den is an optional parameter to shorten the types presented to the user in the case when @p Den equals `1`. */ -template +template requires(detail::valid_ratio && detail::positive_ratio && !detail::ratio_one) struct power { using factor = F; @@ -141,7 +141,7 @@ constexpr bool is_specialization_of_power = false; template constexpr bool is_specialization_of_power> = true; -template +template consteval auto power_or_T_impl() { if constexpr (is_specialization_of_power) { @@ -158,7 +158,7 @@ consteval auto power_or_T_impl() } } -template +template // template // TODO ICE gcc 12 using power_or_T = decltype(power_or_T_impl()); @@ -309,7 +309,7 @@ struct expr_fractions_result { using _den_ = Den; // exposition only }; -template +template [[nodiscard]] consteval auto expr_fractions_impl() { constexpr std::size_t size = type_list_size; @@ -337,11 +337,11 @@ template /** * @brief Divides expression template spec to numerator and denominator parts */ -template +template struct expr_fractions : decltype(expr_fractions_impl>()) {}; // expr_make_spec -template typename To> +template typename To> [[nodiscard]] MP_UNITS_CONSTEVAL auto expr_make_spec_impl() { constexpr std::size_t num = type_list_size; @@ -365,7 +365,7 @@ template typename Pred, +template typename Pred, template typename To> [[nodiscard]] MP_UNITS_CONSTEVAL auto get_optimized_expression() { @@ -386,8 +386,8 @@ template typename To, typename OneType, template typename Pred, typename Lhs, - typename Rhs> +template typename To, SymbolicArg OneType, template typename Pred, + typename Lhs, typename Rhs> [[nodiscard]] MP_UNITS_CONSTEVAL auto expr_multiply(Lhs, Rhs) { if constexpr (is_same_v) { @@ -421,8 +421,8 @@ template typename To, typename OneType, template typename To, typename OneType, template typename Pred, typename Lhs, - typename Rhs> +template typename To, SymbolicArg OneType, template typename Pred, + typename Lhs, typename Rhs> [[nodiscard]] MP_UNITS_CONSTEVAL auto expr_divide(Lhs lhs, Rhs rhs) { if constexpr (is_same_v) { @@ -455,7 +455,7 @@ template typename To, typename OneType, template typename To, typename OneType, typename T> +template typename To, SymbolicArg OneType, typename T> [[nodiscard]] consteval auto expr_invert(T) { if constexpr (is_specialization_of) @@ -467,7 +467,7 @@ template typename To, typename OneType, typename T> } -template typename To, typename OneType, +template typename To, SymbolicArg OneType, template typename Pred, typename... Nums, typename... Dens> requires detail::non_zero [[nodiscard]] consteval auto expr_pow_impl(type_list, type_list) @@ -487,7 +487,7 @@ template typename To * @tparam Pred binary less then predicate * @tparam T Expression being the base of the operation */ -template typename To, typename OneType, +template typename To, SymbolicArg OneType, template typename Pred, typename T> requires detail::non_zero [[nodiscard]] consteval auto expr_pow(T v) @@ -551,7 +551,7 @@ template return pow(T{}); } -template typename Proj, template typename To, typename OneType, +template typename Proj, template typename To, SymbolicArg OneType, template typename Pred, expr_type_projectable... Nums, expr_type_projectable... Dens> [[nodiscard]] consteval auto expr_map_impl(type_list, type_list) @@ -569,7 +569,7 @@ template typename Proj, template typename To, ty * @tparam Pred binary less then predicate * @tparam T expression template to map from */ -template typename Proj, template typename To, typename OneType, +template typename Proj, template typename To, SymbolicArg OneType, template typename Pred, expr_projectable T> [[nodiscard]] consteval auto expr_map(T) {