struct opCmp?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri May 15 01:53:40 PDT 2009


Nick Sabalausky wrote:
> Can anyone think of a 
> reasonable case where it would actually make sense to override opCmp, but 
> not opEquals? (that is, without bastardizing them like in a "C++ streams" 
> kind of way) 

How about a struct you want to be opCmp()-comparable (which, according to the 
spec, they aren't by default), but for which equality means bitwise-equality?

Similarly, a class that's uniqued (so there are no equal instances that aren't 
actually the same instance, i.e. comparison means pointer-comparison), yet that 
has some kind of natural ordering implemented through opCmp().


More information about the Digitalmars-d-learn mailing list