All Comparison and Ordering Facilities

All Comparison and Ordering Facilities

A compact scan page for equality, ordering categories, comparators, and three-way comparison support in modern C++.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

All Comparison and Ordering Facilities

Comparison category types

Operators and language support

Comparator objects and utilities

Where ordering shows up in practice

Practical rules

Example in practice

#include <compare>

struct Version {
    int major{};
    int minor{};
    auto operator<=>(const Version&) const = default;
};

int main() {
    return Version{1, 2} < Version{2, 0};
}