opEquals needs to return bool
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 15 09:32:23 PDT 2008
Because opEquals returns int, this breaks some generic code:
bool isEqual(T)(T t1, T t2)
{
return t1 == t2;
}
class A
{
}
void main()
{
int x1 = 5, x2 = 6;
auto x = isEqual(x1, x2);
auto c = isEqual("hello", "jello");
auto a = new A;
auto ae = isEqual(a, a); // error, cannot convert int to bool
}
Walter, you often say that some ideas can't be implemented because it would
break generic code, what about this?
-Steve
More information about the Digitalmars-d
mailing list