Files
cppdraft_translate/cppdraft/cmp/partialord.md
2025-10-25 03:02:53 +03:00

80 lines
4.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[cmp.partialord]
# 17 Language support library [[support]](./#support)
## 17.12 Comparisons [[cmp]](cmp#partialord)
### 17.12.2 Comparison category types [[cmp.categories]](cmp.categories#cmp.partialord)
#### 17.12.2.2 Class partial_ordering [cmp.partialord]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4901)
The partial_ordering type is typically used
as the result type of a three-way comparison operator ([[expr.spaceship]](expr.spaceship "7.6.8Three-way comparison operator"))
for a type that admits
all of the six two-way comparison operators ([[expr.rel]](expr.rel "7.6.9Relational operators"), [[expr.eq]](expr.eq "7.6.10Equality operators")),
for which equality need not imply substitutability,
and that permits two values to be incomparable[.](#1.sentence-1)[190](#footnote-190 "That is, a < b, a == b, and a > b might all be false.")
[🔗](#lib:partial_ordering)
namespace std {class partial_ordering {int *value*; // *exposition only*bool *is-ordered*; // *exposition only*// exposition-only constructorsconstexpr explicit partial_ordering(*ord* v) noexcept : *value*(int(v)), *is-ordered*(true) {} // *exposition only*constexpr explicit partial_ordering(*ncmp* v) noexcept : *value*(int(v)), *is-ordered*(false) {} // *exposition only*public:// valid valuesstatic const partial_ordering less; static const partial_ordering equivalent; static const partial_ordering greater; static const partial_ordering unordered; // comparisonsfriend constexpr bool operator==(partial_ordering v, *unspecified*) noexcept; friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default; friend constexpr bool operator< (partial_ordering v, *unspecified*) noexcept; friend constexpr bool operator> (partial_ordering v, *unspecified*) noexcept; friend constexpr bool operator<=(partial_ordering v, *unspecified*) noexcept; friend constexpr bool operator>=(partial_ordering v, *unspecified*) noexcept; friend constexpr bool operator< (*unspecified*, partial_ordering v) noexcept; friend constexpr bool operator> (*unspecified*, partial_ordering v) noexcept; friend constexpr bool operator<=(*unspecified*, partial_ordering v) noexcept; friend constexpr bool operator>=(*unspecified*, partial_ordering v) noexcept; friend constexpr partial_ordering operator<=>(partial_ordering v, *unspecified*) noexcept; friend constexpr partial_ordering operator<=>(*unspecified*, partial_ordering v) noexcept; }; // valid values' definitionsinline constexpr partial_ordering partial_ordering::less(*ord*::*less*); inline constexpr partial_ordering partial_ordering::equivalent(*ord*::*equivalent*); inline constexpr partial_ordering partial_ordering::greater(*ord*::*greater*); inline constexpr partial_ordering partial_ordering::unordered(*ncmp*::*unordered*);}
[🔗](#lib:operator==,partial_ordering)
`constexpr bool operator==(partial_ordering v, unspecified) noexcept;
constexpr bool operator< (partial_ordering v, unspecified) noexcept;
constexpr bool operator> (partial_ordering v, unspecified) noexcept;
constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4973)
*Returns*: For operator@, v.*is-ordered* && v.*value* @ 0[.](#2.sentence-1)
[🔗](#lib:operator%3c,partial_ordering_)
`constexpr bool operator< (unspecified, partial_ordering v) noexcept;
constexpr bool operator> (unspecified, partial_ordering v) noexcept;
constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4990)
*Returns*: For operator@, v.*is-ordered* && 0 @ v.*value*[.](#3.sentence-1)
[🔗](#lib:operator%3c=%3e,partial_ordering)
`constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5001)
*Returns*: v[.](#4.sentence-1)
[🔗](#lib:operator%3c=%3e,partial_ordering_)
`constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5012)
*Returns*: v < 0 ? partial_ordering::greater : v > 0 ? partial_ordering::less : v[.](#5.sentence-1)
[190)](#footnote-190)[190)](#footnoteref-190)
That is, a < b, a == b, and a > b might all be false[.](#footnote-190.sentence-1)