>>> For example a < b is re-written as a.opCmp(b) < 0.
>>> In my application, I wanted to overload comparison and equality
>>> operators to return user defined values. Is that possible in D? If so
>>> how?
>>
>> What are you trying to do?
>> In the end opCmp can return any value or object that works in the
>> rewritten case 'a.opCmp(b) < 0'.
>
> Which is a fancy way of returning an int. Probably he wants to implement
> expression templates.
>

Actually not expression templates. I am porting a BDD (Binary decision
diagrams) library from C++ to D. The comparison operators are just
implemented as relations that return another BDD. A BDD would then
evaluate to 0 or 1 depending on many other factors and other BDDs. A
BDD actually represents a node on an acyclic graph.

Being able to overload comparison operators more generically would
have helped. For now I am using named functions as Timon suggested.

Regards
- Puneet

Reply via email to