3 ms·
I can imagine this happening in template code: template <typename T> bool isNumberInfinity(T number) { return isinf(number); } tem
by solinent 13y ago
I can imagine this happening in template code:
template <typename T>
bool isNumberInfinity(T number)
{
return isinf(number);
}
template <>
bool isNumberInfinity(Number number)
{
return number == Number::INF;
}
So instead of specializing ints, we rely on isinf working for ints, instead of doing the "correct" thing:
template <>
bool isNumberInfinity(int number)
{
return false;
}
This is a very contrived since I'm using template functions, which are practically useless, but it holds for any data structure which holds a type that is meant to behave somewhat like a "number".
- pbsd 13y agoWhat do you mean by "template functions are practically useless"?