I strongly recommend that only the const version should be defined. That
would work on both mutable and immutable objects.
Besides, opEquals should not modify the object anyway; that would be
surprising.
Ali

rhs.y; }
I strongly recommend that only the const version should be
defined. That would work on both mutable and immutable objects.
Besides, opEquals should not modify the object anyway; that
would be surprising.
Ali

Design & Style aside. Shouldn't this be possible?
I do have std.Tuple in mind, which can have members of any type.
If one of these does not have a const opEquals, comparison is
unnecessary restricted to mutable instances.

The standard way to define opEquals at this point would be to have
bool opEquals(const Point rhs) {return this == rhs;}
bool opEquals(const ref Point rhs) {...}
I don't know if templatizing it causes problems or not. And if you can't have
it work with const for some reason, then remove the const modifiers on both.
But assuming that templatizing it works, since it's a template, you could
probably just do one definition with auto ref:
bool opEquals(R)(auto const ref rhs) const {...}
There have been some discussions on adjusting how const ref and/or auto ref
works which would make it so that only one signature was required even without
templates, but that hasn't been sorted out yet.
- Jonathan M Davis