Header Reference: <compare>
Header Reference: <compare>
Three-way comparison categories, defaulted comparisons, and comparison helpers from <compare>.
Header Reference: <compare>
Three-way comparison categories, defaulted comparisons, and comparison helpers from <compare>.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
Header reference pages are meant to answer a practical question quickly: what this header provides, when to reach for it, and which usage rules are easiest to get wrong.
<compare>std::strong_ordering, std::weak_ordering, std::partial_orderingstd::strong_equality, std::weak_equality where supported by the implementation and standard modestd::compare_three_waystd::ranges::lessUse <compare> with the spaceship operator <=>, defaulted comparisons, and generic code that needs explicit ordering-category types.
operator<=> for user-defined types#include <compare>
int main() {
// Start with the primary facility from <compare>.
// Then verify lifetime, invalidation, ordering, or error-handling rules.
return 0;
}