From b3afd61b2d70a656c263cbc6378b3d06f7921c06 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 11 May 2022 22:55:55 +0200 Subject: [PATCH] refactor: duplicated concepts checks removed to improve compile times `magnitude` template parameters are already checked during `magnitude` type instantiation. --- src/core/include/units/magnitude.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index c51285e2..4b95c6e4 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -370,7 +370,7 @@ struct magnitude { namespace detail { template inline constexpr bool is_magnitude = false; -template +template inline constexpr bool is_magnitude> = true; } // namespace detail @@ -383,7 +383,7 @@ concept Magnitude = detail::is_magnitude; /** * @brief The value of a Magnitude in a desired type T. */ -template +template // TODO(chogg): Migrate this to use `treat_as_floating_point`. requires(!std::is_integral_v || is_integral(magnitude{})) constexpr T get_value(const magnitude&) @@ -404,7 +404,7 @@ struct pi_base { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Magnitude equality implementation. -template +template constexpr bool operator==(magnitude, magnitude) { if constexpr (sizeof...(LeftBPs) == sizeof...(RightBPs)) { @@ -417,7 +417,7 @@ constexpr bool operator==(magnitude, magnitude) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Magnitude rational powers implementation. -template +template constexpr auto pow(magnitude) { if constexpr (E == 0) { @@ -427,13 +427,13 @@ constexpr auto pow(magnitude) } } -template +template constexpr auto sqrt(magnitude m) { return pow(m); } -template +template constexpr auto cbrt(magnitude m) { return pow(m); @@ -448,7 +448,7 @@ constexpr auto operator*(magnitude<>, Magnitude auto m) { return m; } constexpr auto operator*(Magnitude auto m, magnitude<>) { return m; } // Recursive case for the product of any two non-identity Magnitudes. -template +template constexpr auto operator*(magnitude, magnitude) { // Case for when H1 has the smaller base. @@ -495,7 +495,7 @@ constexpr auto operator/(Magnitude auto l, Magnitude auto r) { return l * pow<-1 namespace detail { // The largest integer which can be extracted from any magnitude with only a single basis vector. -template +template constexpr auto integer_part(magnitude) { constexpr auto power_num = numerator(BP.power); @@ -515,7 +515,7 @@ constexpr auto integer_part(magnitude) } // namespace detail -template +template constexpr auto numerator(magnitude) { return (detail::integer_part(magnitude{}) * ... * magnitude<>{}); @@ -553,7 +553,7 @@ constexpr ratio as_ratio(Magnitude auto m) // minimum power for each base (where absent bases implicitly have a power of 0). namespace detail { -template +template constexpr auto remove_positive_power(magnitude m) { if constexpr (numerator(BP.power) < 0) { @@ -563,7 +563,7 @@ constexpr auto remove_positive_power(magnitude m) } } -template +template constexpr auto remove_positive_powers(magnitude) { return (magnitude<>{} * ... * remove_positive_power(magnitude{})); @@ -576,7 +576,7 @@ constexpr auto common_magnitude(magnitude<>, Magnitude auto m) { return detail:: constexpr auto common_magnitude(Magnitude auto m, magnitude<>) { return detail::remove_positive_powers(m); } // Recursive case for the common Magnitude of any two non-identity Magnitudes. -template +template constexpr auto common_magnitude(magnitude m1, magnitude m2) { using detail::remove_positive_power;