forked from mpusz/mp-units
Make pow()'s argument a simple (non-template) parameter
This commit is contained in:
@@ -128,9 +128,8 @@ constexpr bool operator==(T t, U u) {
|
|||||||
/**
|
/**
|
||||||
* @brief A BasePower, raised to a rational power E.
|
* @brief A BasePower, raised to a rational power E.
|
||||||
*/
|
*/
|
||||||
template<ratio E>
|
constexpr auto pow(BasePower auto bp, ratio p) {
|
||||||
constexpr auto pow(BasePower auto bp) {
|
bp.power = bp.power * p;
|
||||||
bp.power = bp.power * E;
|
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +273,7 @@ constexpr bool operator==(magnitude<LeftBPs...>, magnitude<RightBPs...>) {
|
|||||||
template<ratio E, BasePower auto... BPs>
|
template<ratio E, BasePower auto... BPs>
|
||||||
constexpr auto pow(magnitude<BPs...>) {
|
constexpr auto pow(magnitude<BPs...>) {
|
||||||
if constexpr (E == 0) { return magnitude<>{}; }
|
if constexpr (E == 0) { return magnitude<>{}; }
|
||||||
else { return magnitude<pow<E>(BPs)...>{}; }
|
else { return magnitude<pow(BPs, E)...>{}; }
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@@ -98,9 +98,9 @@ TEST_CASE("base_power")
|
|||||||
|
|
||||||
SECTION("pow() multiplies exponent")
|
SECTION("pow() multiplies exponent")
|
||||||
{
|
{
|
||||||
CHECK(pow<0>(base_power{2}) == base_power{2, 0});
|
CHECK(pow(base_power{2}, 0) == base_power{2, 0});
|
||||||
CHECK(pow<ratio{-1, 2}>(base_power{2, 3}) == base_power{2, ratio{-3, 2}});
|
CHECK(pow(base_power{2, 3}, ratio{-1, 2}) == base_power{2, ratio{-3, 2}});
|
||||||
CHECK(pow<ratio{1, 3}>(base_power<pi_base>{ratio{3, 2}}) == base_power<pi_base>{ratio{1, 2}});
|
CHECK(pow(base_power<pi_base>{ratio{3, 2}}, ratio{1, 3}) == base_power<pi_base>{ratio{1, 2}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user