Please help me with any flaws in logic or understanding:
For any struct S, '==' means either bitwise comparison or a call
to opEquals of S if it exists.
If S has no (dynamic arrays, associative arrays, pointers, or
class references as members (recursively)) then bitwise compare
is equivalent to a deep compare.
But if you do have any of those and you want true deep comparison
semantics, you must implement a correct opEquals at the first
introduction of those members, and carry that forward through all
composed structures to S.
struct A { int x = 3; }
struct B { A a; }
struct C { B b; }
struct D { C c; }
So in this case, D has deep equality semantics for ==.
But change A to struct A { string x; } and the deep equality
semantics for D disappears. To get it back an opEquals must be
correctly implemented in A, B, C, and D.
Is this accurate?
If true and not an issue, people must not be relying too much on
deep equality semantics like this. But how else can you find
things?
Thanks
Dan