From 08818ac6a8292dfa234b48434cd2b7b11f77c1ee Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Tue, 11 Jan 2022 19:19:25 -0500 Subject: [PATCH] Make pow()'s argument a simple (non-template) parameter --- src/core/include/units/magnitude.h | 7 +++---- test/unit_test/runtime/magnitude_test.cpp | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index 7427e9dd..63b510aa 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -128,9 +128,8 @@ constexpr bool operator==(T t, U u) { /** * @brief A BasePower, raised to a rational power E. */ -template -constexpr auto pow(BasePower auto bp) { - bp.power = bp.power * E; +constexpr auto pow(BasePower auto bp, ratio p) { + bp.power = bp.power * p; return bp; } @@ -274,7 +273,7 @@ constexpr bool operator==(magnitude, magnitude) { template constexpr auto pow(magnitude) { if constexpr (E == 0) { return magnitude<>{}; } - else { return magnitude(BPs)...>{}; } + else { return magnitude{}; } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index f37a5cee..f5eaf0e3 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -98,9 +98,9 @@ TEST_CASE("base_power") SECTION("pow() multiplies exponent") { - CHECK(pow<0>(base_power{2}) == base_power{2, 0}); - CHECK(pow(base_power{2, 3}) == base_power{2, ratio{-3, 2}}); - CHECK(pow(base_power{ratio{3, 2}}) == base_power{ratio{1, 2}}); + CHECK(pow(base_power{2}, 0) == base_power{2, 0}); + CHECK(pow(base_power{2, 3}, ratio{-1, 2}) == base_power{2, ratio{-3, 2}}); + CHECK(pow(base_power{ratio{3, 2}}, ratio{1, 3}) == base_power{ratio{1, 2}}); } }