http://d.puremagic.com/issues/show_bug.cgi?id=3967
Summary: bool opEquals() for structs instead of int opEquals() Product: D Version: 2.041 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2010-03-15 10:23:12 PDT --- This page: http://www.digitalmars.com/d/2.0/operatoroverloading.html Contains: If structs declare an opEquals member function, it should follow the following form: struct S { int opEquals(ref const S s) { ... } } But opEquals of classes returns a boolean, so I think it's better for opEquals of structs too to return a boolean. I think you must be sure opEquals returns a bool. So the specs can be changed into something like: struct S { bool opEquals(ref const(S) s) { ... } } Currently this code runs: import std.c.stdio: printf; struct Foo { int data; int opEquals(T:Foo)(T other) { printf("A"); return this.data == other.data; } } void main() { int r = Foo(5) == Foo(5); } But I think dmd has to raise a c error, and require something like: bool opEquals(T:Foo)(ref const(Foo) other) { Or: bool opEquals(T:Foo)(const(Foo) other) { etc. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------