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

4.9 KiB
Raw Permalink Blame History

[cmp.strongord]

17 Language support library [support]

17.12 Comparisons [cmp]

17.12.2 Comparison category types [cmp.categories]

17.12.2.4 Class strong_ordering [cmp.strongord]

1

#

The strong_ordering type is typically used as the result type of a three-way comparison operator ([expr.spaceship]) for a type that admits all of the six two-way comparison operators ([expr.rel], [expr.eq]) and for which equality does imply substitutability.

🔗

namespace std {class strong_ordering {int value; // exposition only// exposition-only constructorsconstexpr explicit strong_ordering(ord v) noexcept : value(int(v)) {} // exposition onlypublic:// valid valuesstatic const strong_ordering less; static const strong_ordering equal; static const strong_ordering equivalent; static const strong_ordering greater; // conversionsconstexpr operator partial_ordering() const noexcept; constexpr operator weak_ordering() const noexcept; // comparisonsfriend constexpr bool operator==(strong_ordering v, unspecified) noexcept; friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default; friend constexpr bool operator< (strong_ordering v, unspecified) noexcept; friend constexpr bool operator> (strong_ordering v, unspecified) noexcept; friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept; friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept; friend constexpr bool operator< (unspecified, strong_ordering v) noexcept; friend constexpr bool operator> (unspecified, strong_ordering v) noexcept; friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept; friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept; friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept; friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept; }; // valid values' definitionsinline constexpr strong_ordering strong_ordering::less(ord::less); inline constexpr strong_ordering strong_ordering::equal(ord::equal); inline constexpr strong_ordering strong_ordering::equivalent(ord::equivalent); inline constexpr strong_ordering strong_ordering::greater(ord::greater);}

🔗

constexpr operator partial_ordering() const noexcept;

2

#

Returns: value == 0 ? partial_ordering::equivalent :value < 0 ? partial_ordering::less : partial_ordering::greater

🔗

constexpr operator weak_ordering() const noexcept;

3

#

Returns: value == 0 ? weak_ordering::equivalent :value < 0 ? weak_ordering::less : weak_ordering::greater

🔗

constexpr bool operator==(strong_ordering v, unspecified) noexcept; constexpr bool operator< (strong_ordering v, unspecified) noexcept; constexpr bool operator> (strong_ordering v, unspecified) noexcept; constexpr bool operator<=(strong_ordering v, unspecified) noexcept; constexpr bool operator>=(strong_ordering v, unspecified) noexcept;

4

#

Returns: v.value @ 0 for operator@.

🔗

constexpr bool operator< (unspecified, strong_ordering v) noexcept; constexpr bool operator> (unspecified, strong_ordering v) noexcept; constexpr bool operator<=(unspecified, strong_ordering v) noexcept; constexpr bool operator>=(unspecified, strong_ordering v) noexcept;

5

#

Returns: 0 @ v.value for operator@.

🔗

constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;

6

#

Returns: v.

🔗

constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;

7

#

Returns: v < 0 ? strong_ordering::greater : v > 0 ? strong_ordering::less : v.