[cmp.strongord] (original) (raw)
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; constexpr explicit strong_ordering(ord v) noexcept : value(int(v)) {} public: static const strong_ordering less;static const strong_ordering equal;static const strong_ordering equivalent;static const strong_ordering greater;constexpr operator partial_ordering() const noexcept;constexpr operator weak_ordering() const noexcept;friend 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;};inline 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);}
Returns: value == 0 ? partial_ordering::equivalent :value < 0 ? partial_ordering::less : partial_ordering::greater
Returns: value == 0 ? weak_ordering::equivalent :value < 0 ? weak_ordering::less : weak_ordering::greater
Returns: v < 0 ? strong_ordering::greater : v > 0 ? strong_ordering::less : v.