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}}); } }