Do not pass integers to isnan (#1664)

This commit is contained in:
Cheng 2024-12-08 11:26:23 +09:00 committed by GitHub
parent 9635cffdc8
commit 6ae5423b4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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));
}
}
};