forked from mpusz/mp-units
pow<0> support added
This commit is contained in:
@@ -27,6 +27,13 @@
|
|||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
|
template<std::size_t N, typename U, typename Rep>
|
||||||
|
requires N == 0
|
||||||
|
inline Rep AUTO pow(const quantity<U, Rep>&) noexcept
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
template<std::size_t N, typename U, typename Rep>
|
template<std::size_t N, typename U, typename Rep>
|
||||||
inline Quantity AUTO pow(const quantity<U, Rep>& q) noexcept
|
inline Quantity AUTO pow(const quantity<U, Rep>& q) noexcept
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,7 @@ using namespace units;
|
|||||||
|
|
||||||
TEST_CASE("pow<N>() on quantity changes the value and the dimension accordingly", "[math][pow]")
|
TEST_CASE("pow<N>() on quantity changes the value and the dimension accordingly", "[math][pow]")
|
||||||
{
|
{
|
||||||
// CHECK(pow<0>(2m) == 2);
|
CHECK(pow<0>(2m) == 1);
|
||||||
CHECK(pow<1>(2m) == 2m);
|
CHECK(pow<1>(2m) == 2m);
|
||||||
CHECK(pow<2>(2m) == 4sq_m);
|
CHECK(pow<2>(2m) == 4sq_m);
|
||||||
CHECK(pow<3>(2m) == 8cub_m);
|
CHECK(pow<3>(2m) == 8cub_m);
|
||||||
|
@@ -27,6 +27,7 @@ using namespace units;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
static_assert(std::is_same_v<decltype(pow<0>(2m)), std::int64_t>);
|
||||||
static_assert(std::is_same_v<decltype(pow<1>(2m)), decltype(2m)>);
|
static_assert(std::is_same_v<decltype(pow<1>(2m)), decltype(2m)>);
|
||||||
static_assert(std::is_same_v<decltype(pow<2>(2m)), decltype(4sq_m)>);
|
static_assert(std::is_same_v<decltype(pow<2>(2m)), decltype(4sq_m)>);
|
||||||
static_assert(std::is_same_v<decltype(sqrt(4sq_m)), decltype(2m)>);
|
static_assert(std::is_same_v<decltype(sqrt(4sq_m)), decltype(2m)>);
|
||||||
|
Reference in New Issue
Block a user