Is there a more compact way to describe the opCmp function in the following struct

struct Hit
{
    size_t count; // number of walkers that found this node
NWeight rank; // rank (either minimum distance or maximum strength)

    auto opCmp(const Hit rhs) const
    {
        if      (this.count < rhs.count)
        {
            return -1;
        }
        else if (this.count > rhs.count)
        {
            return +1;
        }
        else
        {
            if      (this.rank < rhs.rank)
            {
                return -1;
            }
            else if (this.rank > rhs.rank)
            {
                return +1;
            }
            else
            {
                return 0;
            }
        }
    }
}

by reusing something like

    auto opCmp(const Hit rhs) const
    {
        if      (this.count < rhs.count)
        {
            return -1;
        }
        else if (this.count > rhs.count)
        {
            return +1;
        }
        else
        {
            return this.rank.standardOpCmp(rhs.rank)
        }
    }

Reply via email to