Standard library header <compare> (C++20)
From cppreference.net
Dieser Header ist Teil der Sprachunterstützungsbibliothek .
Konzepte |
||
|
spezifiziert, dass der Operator
<=>
konsistente Ergebnisse für gegebene Typen liefert
(Konzept) |
||
Klassen |
||
|
(C++20)
|
der Ergebnistyp des 3-Wege-Vergleichs, der alle 6 Operatoren unterstützt, nicht substituierbar ist und unvergleichbare Werte erlaubt
(Klasse) |
|
|
(C++20)
|
Der Ergebnistyp des 3-Wege-Vergleichs, der alle 6 Operatoren unterstützt und nicht substituierbar ist
(Klasse) |
|
|
(C++20)
|
der Ergebnistyp des 3-Wege-Vergleichs, der alle 6 Operatoren unterstützt und substituierbar ist
(Klasse) |
|
|
(C++20)
|
die stärkste Vergleichskategorie, in die alle gegebenen Typen konvertiert werden können
(Klassen-Template) |
|
|
(C++20)
|
ermittelt den Ergebnistyp des Drei-Wege-Vergleichsoperators
<=>
für gegebene Typen
(Klassentemplate) |
|
|
(C++20)
|
eingeschränktes Funktionsobjekt, das
x
<=>
y
implementiert
(Klasse) |
|
Customization Point Objects |
||
|
(C++20)
|
führt einen 3-Wege-Vergleich durch und erzeugt ein Ergebnis vom Typ
std::strong_ordering
(Anpassungspunktobjekt) |
|
|
(C++20)
|
führt einen 3-Wege-Vergleich durch und erzeugt ein Ergebnis vom Typ
std::weak_ordering
(Customization Point Object) |
|
|
(C++20)
|
führt einen 3-Wege-Vergleich durch und erzeugt ein Ergebnis vom Typ
std::partial_ordering
(Anpassungspunktobjekt) |
|
|
(C++20)
|
führt einen 3-Wege-Vergleich durch und erzeugt ein Ergebnis vom Typ
std::strong_ordering
, selbst wenn
operator
<=>
nicht verfügbar ist
(Anpassungspunktobjekt) |
|
|
(C++20)
|
führt einen 3-Wege-Vergleich durch und erzeugt ein Ergebnis vom Typ
std::weak_ordering
, selbst wenn
operator
<=>
nicht verfügbar ist
(Anpassungspunktobjekt) |
|
|
(C++20)
|
führt einen 3-Wege-Vergleich durch und erzeugt ein Ergebnis vom Typ
std::partial_ordering
, selbst wenn
operator
<=>
nicht verfügbar ist
(Anpassungspunktobjekt) |
|
Funktionen |
||
|
Benannte Vergleichsfunktionen
(Funktion) |
||
Übersicht
namespace std { // Vergleichskategorien-Typen class partial_ordering; class weak_ordering; class strong_ordering; // benannte Vergleichsfunktionen constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; } constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; } constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; } constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; } constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; } constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; } // gemeinsamer Vergleichskategorien-Typ template<class... Ts> struct common_comparison_category { using type = /* siehe Beschreibung */; }; template<class... Ts> using common_comparison_category_t = typename common_comparison_category<Ts...>::type; // Konzept three_way_comparable template<class T, class Cat = partial_ordering> concept three_way_comparable = /* siehe Beschreibung */; template<class T, class U, class Cat = partial_ordering> concept three_way_comparable_with = /* siehe Beschreibung */; // Ergebnis des Drei-Wege-Vergleichs template<class T, class U = T> struct compare_three_way_result; template<class T, class U = T> using compare_three_way_result_t = typename compare_three_way_result<T, U>::type; // Klasse compare_three_way struct compare_three_way; // Vergleichsalgorithmen inline namespace /* nicht spezifiziert */ { inline constexpr /* nicht spezifiziert */ strong_order = /* nicht spezifiziert */; inline constexpr /* nicht spezifiziert */ weak_order = /* nicht spezifiziert */; inline constexpr /* nicht spezifiziert */ partial_order = /* nicht spezifiziert */; inline constexpr /* nicht spezifiziert */ compare_strong_order_fallback = /* nicht spezifiziert */; inline constexpr /* nicht spezifiziert */ compare_weak_order_fallback = /* nicht spezifiziert */; inline constexpr /* nicht spezifiziert */ compare_partial_order_fallback = /* nicht spezifiziert */; } }
Konzept
three_way_comparable
namespace std { template<class T, class Cat> concept __ComparesAs = // nur zur Darstellung same_as<common_comparison_category_t<T, Cat>, Cat>; template<class T, class U> concept __PartiallyOrderedWith = // nur zur Darstellung requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t < u } -> boolean-testable; { t > u } -> boolean-testable; { t <= u } -> boolean-testable; { t >= u } -> boolean-testable; { u < t } -> boolean-testable; { u > t } -> boolean-testable; { u <= t } -> boolean-testable; { u >= t } -> boolean-testable; }; template<class T, class Cat = partial_ordering> concept three_way_comparable = __WeaklyEqualityComparableWith<T, T> && __PartiallyOrderedWith<T, T> && requires(const remove_reference_t<T>& a, const remove_reference_t<T>& b) { { a <=> b } -> __ComparesAs<Cat>; }; }
Konzept
three_way_comparable_with
namespace std { template<class T, class U, class Cat = partial_ordering> Konzept three_way_comparable_with = __WeaklyEqualityComparableWith<T, U> && __PartiallyOrderedWith<T, U> && three_way_comparable<T, Cat> && three_way_comparable<U, Cat> && common_reference_with<const remove_reference_t<T>&, const remove_reference_t<U>&> && three_way_comparable< common_reference_t< const remove_reference_t<T>&, const remove_reference_t<U>&>, Cat> && erfordert(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t <=> u } -> __ComparesAs<Cat>; { u <=> t } -> __ComparesAs<Cat>; }; }
Klasse std:: partial_ordering
namespace std { class partial_ordering { int value; // nur zur Darstellung bool is_ordered; // nur zur Darstellung // Nur-Darstellung-Konstruktoren constexpr explicit partial_ordering(eq v) noexcept : value(int(v)), is_ordered(true) {} // nur zur Darstellung constexpr explicit partial_ordering(ord v) noexcept : value(int(v)), is_ordered(true) {} // nur zur Darstellung constexpr explicit partial_ordering(ncmp v) noexcept : value(int(v)), is_ordered(false) {} // nur zur Darstellung public: // gültige Werte static const partial_ordering less; static const partial_ordering equivalent; static const partial_ordering greater; static const partial_ordering unordered; // Vergleiche friend 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; }; // Definitionen der gültigen Werte inline constexpr partial_ordering partial_ordering::less(ord::less); inline constexpr partial_ordering partial_ordering::equivalent(eq::equivalent); inline constexpr partial_ordering partial_ordering::greater(ord::greater); inline constexpr partial_ordering partial_ordering::unordered(ncmp::unordered); }
Klasse std:: weak_ordering
namespace std { class weak_ordering { int value; // nur zur Darstellung // Nur-Darstellungskonstruktoren constexpr explicit weak_ordering(eq v) noexcept : value(int(v)) {} // nur zur Darstellung constexpr explicit weak_ordering(ord v) noexcept : value(int(v)) {} // nur zur Darstellung public: // gültige Werte static const weak_ordering less; static const weak_ordering equivalent; static const weak_ordering greater; // Konvertierungen constexpr operator partial_ordering() const noexcept; // Vergleiche friend constexpr bool operator==(weak_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default; friend constexpr bool operator< (weak_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator> (weak_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator<=(weak_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator>=(weak_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator< (/* nicht spezifiziert */, weak_ordering v) noexcept; friend constexpr bool operator> (/* nicht spezifiziert */, weak_ordering v) noexcept; friend constexpr bool operator<=(/* nicht spezifiziert */, weak_ordering v) noexcept; friend constexpr bool operator>=(/* nicht spezifiziert */, weak_ordering v) noexcept; friend constexpr weak_ordering operator<=>(weak_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr weak_ordering operator<=>(/* nicht spezifiziert */, weak_ordering v) noexcept; }; // Definitionen der gültigen Werte inline constexpr weak_ordering weak_ordering::less(ord::less); inline constexpr weak_ordering weak_ordering::equivalent(eq::equivalent); inline constexpr weak_ordering weak_ordering::greater(ord::greater); }
Klasse std:: strong_ordering
namespace std { class strong_ordering { int value; // nur zur Darstellung // Nur-Darstellungskonstruktoren constexpr explicit strong_ordering(eq v) noexcept : value(int(v)) {} // nur zur Darstellung constexpr explicit strong_ordering(ord v) noexcept : value(int(v)) {} // nur zur Darstellung public: // gültige Werte static const strong_ordering less; static const strong_ordering equal; static const strong_ordering equivalent; static const strong_ordering greater; // Konvertierungen constexpr operator partial_ordering() const noexcept; constexpr operator weak_ordering() const noexcept; // Vergleiche friend constexpr bool operator==(strong_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default; friend constexpr bool operator< (strong_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator> (strong_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator<=(strong_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator>=(strong_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr bool operator< (/* nicht spezifiziert */, strong_ordering v) noexcept; friend constexpr bool operator> (/* nicht spezifiziert */, strong_ordering v) noexcept; friend constexpr bool operator<=(/* nicht spezifiziert */, strong_ordering v) noexcept; friend constexpr bool operator>=(/* nicht spezifiziert */, strong_ordering v) noexcept; friend constexpr strong_ordering operator<=>(strong_ordering v, /* nicht spezifiziert */) noexcept; friend constexpr strong_ordering operator<=>(/* nicht spezifiziert */, strong_ordering v) noexcept; }; // Definitionen der gültigen Werte inline constexpr strong_ordering strong_ordering::less(ord::less); inline constexpr strong_ordering strong_ordering::equal(eq::equal); inline constexpr strong_ordering strong_ordering::equivalent(eq::equivalent); inline constexpr strong_ordering strong_ordering::greater(ord::greater); }
Klasse std:: compare_three_way
namespace std { struct compare_three_way { template<class T, class U> constexpr auto operator()(T&& t, U&& u) const; using is_transparent = /* nicht spezifiziert */; }; }
Siehe auch
Drei-Wege-Vergleichsoperator
Ausdruck
lhs
<=>
rhs
(C++20)
|