On Thu, 29 Sep 2011 11:09:13 -0400, Christophe
<trav...@phare.normalesup.org> wrote:
"Steven Schveighoffer" , dans le message (digitalmars.D:145738), a
It is always possible for a non-const version of opEqual to forward to
the const version, so people willing to use a const version do not have
to define a non-const version.
Again, you still need to define both, this is not a good situation.
No, I didn't express myself correctly. The non-const version should
forward to the const version *by default*.
Fine, but if you want to define a non-const version that *doesn't* call
the const version, you have to define both. So even if you *don't* want
to deal with const, you still do. I should have been clearer, sorry.
Note that the compiler currently calls a global method which accepts two
non-const Objects. In order for it to support both const and mutable
versions, it would have to have 4 different functions.
I really don't think all this complexity is worth the benefit. Just learn
to use const properly, or don't use the operator system to do
comparisons. Object.opEquals should be const.
-Steve