On Tuesday, 7 August 2012 at 16:46:04 UTC, Ali Çehreli wrote:
On 08/07/2012 06:40 AM, Tobias Pankrath wrote:

> bool opEquals(R)(R rhs) { return x == rhs.x && y == rhs.y; }
> bool opEquals(R)(R rhs) const { return x == rhs.x && y ==
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.

Reply via email to