Kagamin wrote:
Don Wrote:
Why are they templated to begin with? Just for the heck of it?
bool opEquals(ref const BigInt y) const
bool opEquals(long y) const
No, because then it fails for ulong.
It's those bloody C implicit conversions.
hmm... works for me:
---
struct A
{
bool opEquals(ref const A y) const
{
return false;
}
bool opEquals(long y) const
{
return true;
}
}
int main()
{
A a;
ulong b=42;
assert(a==b);
return 0;
}
---
Yes, but the code is incorrect if b is larger than long.max.
The problem is that values in the range long.max+1..ulong.max
get turned into values in the range -1 .. -long.max-1
How can you distinguish them?