Skip to content

Commit

Permalink
workaround for windows compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
nmwsharp committed Feb 4, 2025
1 parent 36da8ec commit 5b3a2e4
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion include/polyscope/numeric_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,50 @@ namespace polyscope {
// Base case: call the scalar version
template <typename T>
bool allComponentsFinite(const T& x) {
return std::isfinite(x);
// handle all other scalar types by converting to float, it's what we'll do anyway
return std::isfinite(static_cast<float>(x));
}

// avoid double-to-float rounding infs from the line above
template <>
inline bool allComponentsFinite<double>(const double& x) {
return true;
}

// if we fall through to std::isfinite() for integers, we get compile errors on windows
// due to a name collision with a windows-specific header
// https://github.com/nmwsharp/polyscope/issues/323
template <>
inline bool allComponentsFinite<uint8_t>(const uint8_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<int8_t>(const int8_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<uint16_t>(const uint16_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<int16_t>(const int16_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<uint32_t>(const uint32_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<int32_t>(const int32_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<uint64_t>(const uint64_t& x) {
return true;
}
template <>
inline bool allComponentsFinite<int64_t>(const int64_t& x) {
return true;
}

template <>
Expand Down

0 comments on commit 5b3a2e4

Please sign in to comment.