With this bit of code, the first method seems to work fine - things go as expected. But I get a compile error with the second method, and I'm not sure how else to write this.

    override bool opEquals(Object value) const{
        return this.equals(cast(typeof(this)) value);
    }
    override bool opEquals(T)(T value) const if(isNumeric!(T)){
        return this.equals(value);
    }

The compile errors I get look like this:

C:\path\to\file.d(477): Error: function units.quantity.opEquals!int.opEquals cannot override a non-virtual function C:\path\to\file.d(519): Error: template instance units.quantity.opEquals!int error instantiating

How can I revise this so that I can override comparison operators for things other than class instances?

Reply via email to