Top "Comparison-operators" questions

Comparison operators, as their name implies, allow to compare two values and usually return Boolean value (true or false).

How to overload operator==() for a pointer to the class?

I have a class called AString. It is pretty basic: class AString { public: AString(const char *pSetString = NULL); ~AString(); bool …

c++ pointers operator-overloading comparison-operators
Why is "!=" used with iterators instead of "<"?

I'm used to writing loops like this: for (std::size_t index = 0; index < foo.size(); index++) { // Do stuff with …

c++ stl iterator comparison-operators
JavaScript equality transitivity is weird

I've been reading Douglas Crockford's JavaScript: The Good Parts, and I came across this weird example that doesn't make sense …

javascript comparison-operators equivalence transitivity
Is the operation "false < true" well defined?

Does the C++ specification define: the existence of the 'less than' operator for boolean parameters, and if so, the result …

c++ boolean language-lawyer comparison-operators
Combined Comparison / "Spaceship" Operator (<=>) in Javascript?

Ruby has something called a Combined Comparison or "Spaceship" Operator, it looks like this: <=> It does the following: …

javascript ruby operators comparison-operators spaceship-operator
How is the three-way comparison operator different from subtraction?

There's a new comparison operator <=> in C++20. However I think in most cases a simple subtraction works well: …

c++ comparison-operators c++20 spaceship-operator
What is the comparable interface called?

I'm working on a simple linked list implementation in Go for learning purposes. The definition of an element is below: …

go interface linked-list comparison-operators
Meaning of <=> (less than, equal, greater than) in Perl?

In this answer, I saw the syntax <=>; what does this mean? It seems to be some sort of …

perl comparison operators comparison-operators
What are the default comparison operators for objects?

I found a bug in my code where I forgot to use a custom comparator when sorting a container of …

c++ comparison comparison-operators
operator< comparing multiple fields

I have the following operator< that is supposed to sort first by a value, then by another value: inline …

c++ comparison-operators lexicographic