diff --git a/au/math.hh b/au/math.hh index 34a194c3..feac9cb5 100644 --- a/au/math.hh +++ b/au/math.hh @@ -309,6 +309,12 @@ constexpr bool isnan(Quantity q) { return std::isnan(q.in(U{})); } +// Overload of `isnan` for `QuantityPoint`. +template +constexpr bool isnan(QuantityPoint p) { + return std::isnan(p.in(U{})); +} + // The maximum of two values of the same dimension. // // Unlike std::max, returns by value rather than by reference, because the types might differ. diff --git a/au/math_test.cc b/au/math_test.cc index 5b71b2a1..7a8dd2da 100644 --- a/au/math_test.cc +++ b/au/math_test.cc @@ -601,6 +601,7 @@ TEST(isnan, TransparentlyActsOnSameAsValue) { for (const double x : values) { EXPECT_EQ(isnan(meters(x)), std::isnan(x)); + EXPECT_EQ(isnan(meters_pt(x)), std::isnan(x)); EXPECT_EQ(isnan((radians / second)(x)), std::isnan(x)); } }