http://d.puremagic.com/issues/show_bug.cgi?id=3433
Summary: [tdpl] Comparing structs for equality is not member-by-member Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: and...@metalanguage.com --- Comment #0 from Andrei Alexandrescu <and...@metalanguage.com> 2009-10-21 07:40:35 PDT --- import std.math, std.stdio; struct Point { float x = 0, y = 0; // /*[\textit{\textbf{Added}}]*/ bool opEquals(Point rhs) { // Perform an approximate comparison return approxEqual(x, rhs.x, 1e-3, 1e-5) && approxEqual(y, rhs.y, 1e-3, 1e-5); } } struct Rectangle { Point leftBottom, rightTop; } unittest { Rectangle a, b; assert(a == b); a.leftBottom.x = 1e-8; assert(a == b); a.rightTop.y = 5; assert(a != b); } This fails because Point.opEquals is never called. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------