Charles McAnany:

> Hi, all. So I'm trying to make a BigRational struct, to get more comfortable
> with D.

I suggest to ask similar questions in the D.learn newsgroup.


> bool opEquals(Tdummy = void)(BigRational y){
>       auto temp = this-y;
>       if (temp.numerator == 0)
>       return true;
>       return false;
> }
> 
> bool opEquals(T)(T y){
>       return this == BigRational(y);
> }
> 
> But this is an ambiguity error.

One possible solution:

bool opEquals(T)(T y) if (is(T == BigRational)) { ... }
bool opEquals(T)(T y) if (!is(T == BigRational)) { ... }


Another solution:

bool opEquals(T)(T y) {
    static if (is(T == BigRational)) {
        // ...
    } else {
        // ...
    }
}

Bye,
bearophile

Reply via email to