[Issue 3967] bool opEquals() for structs instead of int opEquals()
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 18 14:30:28 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3967
--- Comment #1 from bearophile_hugs at eml.cc 2010-03-18 14:30:25 PDT ---
This shows why requiring a bool as return value of opEquals is necessary for
generic code too (adapted from an idea of Bill Baxter):
import std.c.stdio: printf;
struct Foo {
int x;
int opEquals(T:Foo)(T other) {
printf("****\n");
return this.x - other.x;
}
}
bool bar(T)(T f1, T f2) {
// return f1 == f2; // ERR
return !!(f1 == f2); // OK, but silly
}
void main() {
bool r = bar(Foo(1), Foo(2));
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list