The Compiler-generated Spaceship Operator
Learn how a three-way comparison operator works.
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.
Get hands-on with 1400+ tech skills courses.