struct opCmp?
Nick Sabalausky
a at a.a
Thu May 14 19:06:13 PDT 2009
"Robert Fraser" <fraserofthenight at gmail.com> wrote in message
news:guihdq$417$3 at digitalmars.com...
> Nick Sabalausky wrote:
>> "Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message
>> news:gui4ml$2g0n$1 at digitalmars.com...
>>> I think you have to use opEquals to overload ==. opCmp only applies to
>>> <, <=, >, and >=.
>>>
>>
>> Oh, I figured either opEquals would be defined in terms of opCmp or an
>> overloaded opCmp would imply a new opEquals defined in terms of it, or
>> something like that.
>
> I think if opCmp is defined and opEquals is not, an opEquals should be
> implicitly defined in terms of opCmp.
Yea, I agree. But at the very least, I was thinking that we could use a
warning when opCmp is defined and opEquals isn't. 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)
More information about the Digitalmars-d-learn
mailing list