c++ - When does it make sense to have separate implementations for operator== and operator!=? -
i heard c++ enables overriding both operator==
, operator!=
because in cases a != b
can implemented more efficient !(a == b)
.
i've thought , can't imagine case true.
what examples makes sense, performance-wise or other, have separate implementations operator==
, operator!=
?
the first example comes mind implementations analogous null value sql. in that, comparing 2 objects—either of null—does not mean equal. if both not null makes sense return equality.
Comments
Post a Comment