All Comparison Function Objects

All Comparison Function Objects

A compact scan page for comparison functors, transparent comparators, and ordering helpers used across algorithms and containers.

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 Function Objects

Core comparison functors

Transparent and ranges-oriented forms

Where they are used

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};
}