Standard library header <compare> (C++20)
From cppreference.net
このヘッダは 言語サポート ライブラリの一部です。
コンセプト |
||
|
指定された型に対して演算子
<=>
が一貫した結果を生成することを指定する
(コンセプト) |
||
クラス |
||
|
(C++20)
|
すべての6つの演算子をサポートし、置換可能ではなく、比較不能な値を許容する3方向比較の結果型
(class) |
|
|
(C++20)
|
すべての6つの演算子をサポートし、置換可能ではない3方向比較の結果型
(クラス) |
|
|
(C++20)
|
すべての6つの演算子をサポートし、置換可能な3方向比較の結果型
(class) |
|
|
(C++20)
|
指定された全ての型が変換可能な最も強い比較カテゴリ
(クラステンプレート) |
|
|
(C++20)
|
指定された型に対する三方比較演算子
<=>
の結果型を取得する
(クラステンプレート) |
|
|
(C++20)
|
x <=> y を実装する制約付き関数オブジェクト
x
<=>
y
(クラス) |
|
カスタマイゼーションポイントオブジェクト |
||
|
(C++20)
|
3方向比較を実行し、型
std::strong_ordering
の結果を生成する
(カスタマイゼーションポイントオブジェクト) |
|
|
(C++20)
|
3方向比較を実行し、型
std::weak_ordering
の結果を生成する
(カスタマイゼーションポイントオブジェクト) |
|
|
(C++20)
|
3方向比較を実行し、型
std::partial_ordering
の結果を生成する
(カスタマイゼーションポイントオブジェクト) |
|
|
(C++20)
|
3方向比較を実行し、型
std::strong_ordering
の結果を生成する。
operator
<=>
が利用できない場合でも実行する
(カスタマイゼーションポイントオブジェクト) |
|
|
(C++20)
|
3方向比較を実行し、結果の型を
std::weak_ordering
で生成する(
operator
<=>
が利用できない場合でも)
(カスタマイゼーションポイントオブジェクト) |
|
|
(C++20)
|
3方向比較を実行し、たとえ
std::partial_ordering
型の結果を生成する
operator
<=>
が利用できない場合でも
(カスタマイゼーションポイントオブジェクト) |
|
関数 |
||
|
名前付き比較関数
(関数) |
||
概要
namespace std { // 比較カテゴリ型 class partial_ordering; class weak_ordering; class strong_ordering; // 名前付き比較関数 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; } // 共通比較カテゴリ型 template<class... Ts> struct common_comparison_category { using type = /* see description */; }; template<class... Ts> using common_comparison_category_t = typename common_comparison_category<Ts...>::type; // コンセプト three_way_comparable template<class T, class Cat = partial_ordering> concept three_way_comparable = /* see description */; template<class T, class U, class Cat = partial_ordering> concept three_way_comparable_with = /* see description */; // 三項比較の結果 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; // クラス compare_three_way struct compare_three_way; // 比較アルゴリズム inline namespace /* unspecified */ { inline constexpr /* unspecified */ strong_order = /* unspecified */; inline constexpr /* unspecified */ weak_order = /* unspecified */; inline constexpr /* unspecified */ partial_order = /* unspecified */; inline constexpr /* unspecified */ compare_strong_order_fallback = /* unspecified */; inline constexpr /* unspecified */ compare_weak_order_fallback = /* unspecified */; inline constexpr /* unspecified */ compare_partial_order_fallback = /* unspecified */; } }
コンセプト
three_way_comparable
namespace std { template<class T, class Cat> concept __ComparesAs = // 説明専用 same_as<common_comparison_category_t<T, Cat>, Cat>; template<class T, class U> concept __PartiallyOrderedWith = // 説明専用 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>; }; }
コンセプト
three_way_comparable_with
namespace std { template<class T, class U, class Cat = partial_ordering> concept 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> && requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t <=> u } -> __ComparesAs<Cat>; { u <=> t } -> __ComparesAs<Cat>; }; }
クラス std:: partial_ordering
namespace std { class partial_ordering { int value; // 説明専用 bool is_ordered; // 説明専用 // 説明専用コンストラクタ constexpr explicit partial_ordering(eq v) noexcept : value(int(v)), is_ordered(true) {} // 説明専用 constexpr explicit partial_ordering(ord v) noexcept : value(int(v)), is_ordered(true) {} // 説明専用 constexpr explicit partial_ordering(ncmp v) noexcept : value(int(v)), is_ordered(false) {} // 説明専用 public: // 有効な値 static const partial_ordering less; static const partial_ordering equivalent; static const partial_ordering greater; static const partial_ordering unordered; // 比較演算 friend constexpr bool operator==(partial_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default; friend constexpr bool operator< (partial_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator> (partial_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator<=(partial_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator>=(partial_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator< (/* 未指定 */, partial_ordering v) noexcept; friend constexpr bool operator> (/* 未指定 */, partial_ordering v) noexcept; friend constexpr bool operator<=(/* 未指定 */, partial_ordering v) noexcept; friend constexpr bool operator>=(/* 未指定 */, partial_ordering v) noexcept; friend constexpr partial_ordering operator<=>(partial_ordering v, /* 未指定 */) noexcept; friend constexpr partial_ordering operator<=>(/* 未指定 */, partial_ordering v) noexcept; }; // 有効な値の定義 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); }
クラス std:: weak_ordering
namespace std { class weak_ordering { int value; // 説明専用 // 説明専用コンストラクタ constexpr explicit weak_ordering(eq v) noexcept : value(int(v)) {} // 説明専用 constexpr explicit weak_ordering(ord v) noexcept : value(int(v)) {} // 説明専用 public: // 有効な値 static const weak_ordering less; static const weak_ordering equivalent; static const weak_ordering greater; // 変換 constexpr operator partial_ordering() const noexcept; // 比較演算 friend constexpr bool operator==(weak_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default; friend constexpr bool operator< (weak_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator> (weak_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator<=(weak_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator>=(weak_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator< (/* 未指定 */, weak_ordering v) noexcept; friend constexpr bool operator> (/* 未指定 */, weak_ordering v) noexcept; friend constexpr bool operator<=(/* 未指定 */, weak_ordering v) noexcept; friend constexpr bool operator>=(/* 未指定 */, weak_ordering v) noexcept; friend constexpr weak_ordering operator<=>(weak_ordering v, /* 未指定 */) noexcept; friend constexpr weak_ordering operator<=>(/* 未指定 */, weak_ordering v) noexcept; }; // 有効な値の定義 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); }
クラス std:: strong_ordering
namespace std { class strong_ordering { int value; // 説明専用 // 説明専用コンストラクタ constexpr explicit strong_ordering(eq v) noexcept : value(int(v)) {} // 説明専用 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, /* 未指定 */) noexcept; friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default; friend constexpr bool operator< (strong_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator> (strong_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator<=(strong_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator>=(strong_ordering v, /* 未指定 */) noexcept; friend constexpr bool operator< (/* 未指定 */, strong_ordering v) noexcept; friend constexpr bool operator> (/* 未指定 */, strong_ordering v) noexcept; friend constexpr bool operator<=(/* 未指定 */, strong_ordering v) noexcept; friend constexpr bool operator>=(/* 未指定 */, strong_ordering v) noexcept; friend constexpr strong_ordering operator<=>(strong_ordering v, /* 未指定 */) noexcept; friend constexpr strong_ordering operator<=>(/* 未指定 */, strong_ordering v) noexcept; }; // 有効な値の定義 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); }
クラス 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 = /* 未指定 */; }; }
関連項目
三方比較演算子
式
lhs
<=>
rhs
(C++20)
|