https://issues.dlang.org/show_bug.cgi?id=16657
Walter Bright <bugzi...@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzi...@digitalmars.com --- Comment #2 from Walter Bright <bugzi...@digitalmars.com> --- Since the auto-generated opEquals() theoretically always exists, having it take precedence makes it a problem to wrap other types and defer to it. But the problem does come in when the auto-generated opEquals() would be non-trivial, as in: --- struct A { int x; bool opEquals(int y) { return y == x; } } struct C { int a; A b; alias a this; } static assert(C(1, A(1)) != C(1, A(2))); --- The current state of affairs is that you'll need to write an explicit C.opEquals() if using an 'alias this' and do not wish the operation to be forwarded to it, even if the other fields have non-trivial opEquals() implementations. I suspect that this is the best solution if only because it is easy to understand. It doesn't have any special cases and exceptions. --