Comparison: when operator<() is better than opCmp()

Daniel Keep daniel.keep.lists at gmail.com
Fri Sep 7 19:00:03 PDT 2007



Giuseppe Bilotta wrote:
> Hello all,

Hi.  Excuse me a moment...

> [snip]
> 
> How does the idea sound?

I like the idea conceptually, and there have been cases where I've
wished I could make an overload for the particular comparison as opposed
to all of them (especially in cases where one or more of the operators
simply doesn't make sense).

It would probably complicate the rules a bit; but then, currently
there's the overload of "==" using both opCmp and opEquals, so you've
definitely got precedence on your side.

As an aside, does that opCmp returning a real work?  Using a real to
return NaN for an invalid comparison is a nice idea; I might have to use
that.

In any case, glad to see you are otherwise enjoying yourself.  Look
forward to seeing you in #d :)

	-- Daniel



More information about the Digitalmars-d mailing list