interface opEquals

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Mon Nov 27 21:01:03 UTC 2023


On Monday, 27 November 2023 at 09:53:48 UTC, Antonio wrote:
> ...but why?

All classes (and interfaces I think), at root of inheritance have 
`Object` class, this class defines couple of generic methods, you 
can find this class in object.d btw. One of those methods is 
`bool opEquals(const Object rhs) const`, therefore if you try to 
call opEquals, it could be possible that in some cricumstances 
instead of your overload, one defined on Object is picked up, 
which checks only if rhs is same object as the one invoked upon.

Btw, dunno how the rules for overload set resolution on opEquals 
work, so someone else should check whther this is a bug or 
expected behavior.

Best regards,
Alexandru.


More information about the Digitalmars-d-learn mailing list