On Wednesday, 24 June 2020 at 00:53:58 UTC, H. S. Teoh wrote:
On Tue, Jun 23, 2020 at 11:53:36PM +0000, claptrap via


If your implementations are based on built-in operators, you could use mixins to unify the implementations into one, e.g.:

Ah yeah thats useful, to expand a bit what about if the RHS is a different type?


Point!T opBinary(string op, RHS)(RHS rhs)
{
    static if (is(RHS == Point!float) || is(RHS == Point!double))
    {
        // .. etc..
    }
    else static if (is(RHS == float) || is(RHS == double))
    {
        // etc...
    }
    else static if (is(RHS == float[2]) || is(RHS == double[2]))
    {
        // .. etc...
    }
    assert(0); // type not supported
}

should that be split up?


Reply via email to