Integral types that define opCmp, opEquals

BCS ao at pathlink.com
Tue Mar 6 11:45:35 PST 2007


Reply to Henning,

> Would it be possible/make sense to have int & co behave as if opCmp
> and opEquals where defined for them?
> 
> That would make it easier in some situations to request for any type
> that is comparable, i.e.
> 
> interface Comparable {
> int opCmp(object);
> }
> would match integer & co.
> 
> Alternative would be to have another way to determine if a type is
> comparable
> maybe a a template-thingy (Im not fit enough with templates to say
> if one could write such a thing himself without special handling of
> integral types)
> Henning
> 

untested but it might work:

const T i;
is(i < i);





More information about the Digitalmars-d mailing list