[Issue 3789] comparing a struct with an array member does a bitwise compare

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 9 14:37:34 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3789



--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-02-09 14:37:33 PST ---
that is an unimportant technical difference.  The semantic meaning of the
feature is that if you have a type T, and a struct S fully defined as:

struct S
{
  T member;
}

Then this assert should always pass:

S s1, s2;
... // initialize s1 and s2 to whatever you want
assert((s1 == s2) is (s1.member == s2.member));

Bitwise compare happens to be the comparison operator for all builtins except
for floating point and arrays.  Although opEquals isn't defined, they certainly
have special comparison operators, and those should be invoked when comparing
containing structs.  This is the principle of least surprise, especially when
arrays back types like strings.

-- 
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