This is the code from the C++ standard library remove
code. Why is inequality tested as if (!(*first == val))
instead of if (*first != val)
The EqualityComparable
concept only requires that operator==
be defined.
Consequently, any function that professes to work with types satisfying EqualityComparable
cannot rely on the existence of operator!=
for objects of that type. (unless there are additional requirements that imply the existence of operator!=
).