On Wednesday, 22 January 2020 at 15:11:09 UTC, Jacob Carlborg wrote:
BTW, why don't you implement `opCmp` with the built-in comparison operators. Those are going to get lower to a call to `__cmp`. Something like this:

int opCmp()(const scope typeof(this) that) const @nogc
{
    auto a = this[];
    auto b = that[];
    return a < b ? -1 : (a > b);
}

--
/Jacob Carlborg

I presume

int opCmp()(const scope typeof(this) that) const @nogc
{
    scope const a = this[];
    scope const b = that[];
    return a < b ? -1 : (a > b);
}

is preferred.

Reply via email to