Do not pass integers to isnan (#1664)

This commit is contained in:
Cheng
2024-12-07 18:26:23 -08:00
committed by GitHub
parent 9635cffdc8
commit 6ae5423b4a
+6 -1
View File
@@ -500,7 +500,12 @@ struct Equal {
struct NaNEqual {
template <typename T>
bool operator()(T x, T y) {
return x == y || (std::isnan(x) && std::isnan(y));
if constexpr (std::is_integral_v<T>) {
// isnan always returns false for integers, and MSVC refuses to compile.
return x == y;
} else {
return x == y || (std::isnan(x) && std::isnan(y));
}
}
};