The Compiler-generated Spaceship Operator
Learn how a three-way comparison operator works.
We'll cover the following...
We'll cover the following...
The compiler-generated three-way comparison operator needs the header <compare>, is implicitly constexpr and noexcept, and it performs a lexicographical comparison.
You can even directly use the three-way comparison operator.
Direct use of the three-way comparison operator
The following program directly uses the spaceship operator.
The program uses the spaceship operator for int (line 11), for string (line 18), and vector (line 25). As already mentioned these ...