You can merge this to.
```d
if (is(const S == const T)) || typeid(lhs) is typeid(rhs) || typeid(lhs).opEquals(rhs))
    return lhs.opEquals(rhs);
else
    return lhs.opEquals(rhs) && rhs.opEquals(lhs);
```