Behavior of opEquals

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 17 11:30:22 PDT 2015


On 09/09/2015 09:20 PM, Timon Gehr wrote:
>
> On 09/09/2015 01:32 AM, Jonathan M Davis wrote: (moved from above)
>> I really don't see any reason why it would even make sense to declare
>> operators separately from a type.
>
> One reason is that single dispatch can be awkward. A textbook example
> would be: ...

I just noticed that I missed to concretely mention one obvious use case:

Overloading mutating operators on reference types with ("logical") value 
semantics, possibly in combination with hash consing. E.g. 
classObject++, or classObject+=x.


More information about the Digitalmars-d mailing list