Skip to content

Commit

Permalink
Support QuantityPoint in isnan (#236)
Browse files Browse the repository at this point in the history
Helps #221.
  • Loading branch information
chiphogg authored May 9, 2024
1 parent b9b89f8 commit 5339f61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions au/math.hh
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ constexpr bool isnan(Quantity<U, R> q) {
return std::isnan(q.in(U{}));
}

// Overload of `isnan` for `QuantityPoint`.
template <typename U, typename R>
constexpr bool isnan(QuantityPoint<U, R> 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.
Expand Down
1 change: 1 addition & 0 deletions au/math_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 5339f61

Please sign in to comment.