Skip to content

Commit 5b3a2e4

Browse files
committed
workaround for windows compile error
1 parent 36da8ec commit 5b3a2e4

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

include/polyscope/numeric_helpers.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,50 @@ namespace polyscope {
1313
// Base case: call the scalar version
1414
template <typename T>
1515
bool allComponentsFinite(const T& x) {
16-
return std::isfinite(x);
16+
// handle all other scalar types by converting to float, it's what we'll do anyway
17+
return std::isfinite(static_cast<float>(x));
18+
}
19+
20+
// avoid double-to-float rounding infs from the line above
21+
template <>
22+
inline bool allComponentsFinite<double>(const double& x) {
23+
return true;
24+
}
25+
26+
// if we fall through to std::isfinite() for integers, we get compile errors on windows
27+
// due to a name collision with a windows-specific header
28+
// https://github.com/nmwsharp/polyscope/issues/323
29+
template <>
30+
inline bool allComponentsFinite<uint8_t>(const uint8_t& x) {
31+
return true;
32+
}
33+
template <>
34+
inline bool allComponentsFinite<int8_t>(const int8_t& x) {
35+
return true;
36+
}
37+
template <>
38+
inline bool allComponentsFinite<uint16_t>(const uint16_t& x) {
39+
return true;
40+
}
41+
template <>
42+
inline bool allComponentsFinite<int16_t>(const int16_t& x) {
43+
return true;
44+
}
45+
template <>
46+
inline bool allComponentsFinite<uint32_t>(const uint32_t& x) {
47+
return true;
48+
}
49+
template <>
50+
inline bool allComponentsFinite<int32_t>(const int32_t& x) {
51+
return true;
52+
}
53+
template <>
54+
inline bool allComponentsFinite<uint64_t>(const uint64_t& x) {
55+
return true;
56+
}
57+
template <>
58+
inline bool allComponentsFinite<int64_t>(const int64_t& x) {
59+
return true;
1760
}
1861

1962
template <>

0 commit comments

Comments
 (0)