Best way to compare primitive types
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue May 8 09:38:09 PDT 2007
"Jari-Matti Mäkelä" <jmjmak at utu.fi.invalid> wrote in message
news:f1ppgi$262c$1 at digitalmars.com...
>
> Error: this for compare needs to be type TypeInfo not type Foo *
>
> struct Foo(T) {
> T value;
>
> // or maybe T opCmp(T other) for reals, floats etc.
> // to handle NaN properly
> int opCmp(T other) {
You can use:
return typeid(T).compare(this, &other);
But you've still got the NaN issue..
> }
> }
More information about the Digitalmars-d-learn
mailing list