If I try using isfinite() in my code anywhere i get an error saying C2668 'fpclassify': ambiguous call to overloaded function.
I'm using visual studio.
How could I fix this?
Floating point types can represent some values that aren't numbers. Those are
- positive and negative infinities
- representations of Not-a-Number (NaNs)
You've encountered a library bug - whichever library you're using is missing overloads for integral types. The documentation on this site is also wrong, although Cppreference has it right, specifying the presence of overload(s) of std::isfinite for every integral type: https://en.cppreference.com/w/cpp/numeric/math/isfinite
You're using Visual Studio, right? I'm pretty sure Andy is.
In the upcoming week, I'll look into addressing this issue in Microsoft's C++ standard library if it's not fixed already. I assume the problem extends through the whole of <cmath>.
not as much a bug as a different interpretation of the standard. Based on a lib-ext discussion last year, the way MS saw it is that the more specific clause [c.math.fpclass]/1 "Each function is overloaded for the three floating-point types" wins over the more generic clause [cmath.syn]/2 "there shall be additional overloads sufficient to ensure", while GCC saw it the opposite way.
Yes YogurtMan said he uses VS and I use the 2017 Community version.
Further investigation lead me to the "corecrt_math.h" which appears to be set up to deal with only "float", "double" and "long double".
In the beginning I was more focused on the error than thinking about what Microsoft has left out, but I am seeing this to be more of a problem than I first realized.
I do understand that the reference section here is out of date. I should start using "cppreference.com" more often.