[Issue 5519] Saner struct equality
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 3 03:42:25 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5519
--- Comment #2 from Denis Derman <denis.spir at gmail.com> 2011-02-03 03:40:07 PST ---
(In reply to comment #0)
> Surprisingly this works (DMD 2.051):
>
>
> struct Bar {
> int x;
> const bool opEquals(ref const(Bar) o) {
> return x == o.x || x == -o.x;
> }
> }
> struct Foo { Bar a; }
> void main() {
> auto f1 = Foo(Bar(1));
> auto f2 = Foo(Bar(-1));
> assert(f1 == f2); // this doesn't assert
> }
You probably meant in your comment: "this doesn't throw" didn't you? The
assertion passes, meaning the code behaves with expected semantics.
Denis
--
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