名前空間
変種
操作

標準ライブラリヘッダ <compare>

提供: cppreference.com
< cpp‎ | header
 
 
 

このヘッダは汎用ユーティリティライブラリの一部です。

目次

[編集] クラス

等しい、等しくないのみサポートする代用可能でない三方比較の結果の型
(クラス) [edit]
等しい、等しくないのみサポートする代用可能な三方比較の結果の型
(クラス) [edit]
6種類の演算子をすべてサポートし、代用可能でなく、比較不可能な値を許容する、三方比較の結果の型
(クラス) [edit]
6種類の演算子をすべてサポートする代用可能でない三方比較の結果の型
(クラス) [edit]
6種類の演算子をすべてサポートする代用可能な三方比較の結果の型
(クラス) [edit]
指定されたすべての型が変換可能な最も強い比較カテゴリ
(クラステンプレート) [edit]

[編集] 関数

名前付きの比較関数
(関数) [edit]
三方比較を行い std::strong_ordering 型の結果を返します
(関数テンプレート) [edit]
三方比較を行い std::weak_ordering 型の結果を返します
(関数テンプレート) [edit]
三方比較を行い std::partial_ordering 型の結果を返します
(関数テンプレート) [edit]
三方比較を行い std::strong_equality 型の結果を返します
(関数テンプレート) [edit]
三方比較を行い std::weak_equality 型の結果を返します
(関数テンプレート) [edit]

[編集] 概要

namespace std {
  // comparison category types
  class weak_equality;
  class strong_equality;
  class partial_ordering;
  class weak_ordering;
  class strong_ordering;
  // named comparison functions
  constexpr bool is_eq (weak_equality cmp) noexcept { return cmp == 0; }
  constexpr bool is_neq (weak_equality 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; }
  // common comparison category type
  template<class... Ts>
  struct common_comparison_category {
    using type = /* see definition */ ;
  };
  template<class... Ts>
  using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
  // comparison algorithms
  template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
  template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
  template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
  template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
  template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
}

[編集] クラス std::weak_equality

namespace std {
  class weak_equality {
    int value; // exposition only
    // exposition-only constructor
    explicit constexpr weak_equality(eq v) noexcept : value(int(v)) {} // exposition only
    public:
    // valid values
    static const weak_equality equivalent;
    static const weak_equality nonequivalent;
    // comparisons
    friend constexpr bool operator==(weak_equality v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator!=(weak_equality v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator==(/*unspecified*/ , weak_equality v) noexcept;
    friend constexpr bool operator!=(/*unspecified*/ , weak_equality v) noexcept;
  };
  // valid values’ definitions
  inline constexpr weak_equality weak_equality::equivalent(eq::equivalent);
  inline constexpr weak_equality weak_equality::nonequivalent(eq::nonequivalent);
}

[編集] クラス std::strong_equality

namespace std {
  class strong_equality {
    int value; // exposition only
    // exposition-only constructor
    explicit constexpr strong_equality(eq v) noexcept : value(int(v)) {} // exposition only
    public:
    // valid values
    static const strong_equality equal;
    static const strong_equality nonequal;
    static const strong_equality equivalent;
    static const strong_equality nonequivalent;
    // conversion
    constexpr operator weak_equality() const noexcept;
    // comparisons
    friend constexpr bool operator==(strong_equality v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator!=(strong_equality v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator==(/*unspecified*/ , strong_equality v) noexcept;
    friend constexpr bool operator!=(/*unspecified*/ , strong_equality v) noexcept;
  };
  // valid values’ definitions
  inline constexpr strong_equality strong_equality::equal(eq::equal);
  inline constexpr strong_equality strong_equality::nonequal(eq::nonequal);
  inline constexpr strong_equality strong_equality::equivalent(eq::equivalent);
  inline constexpr strong_equality strong_equality::nonequivalent(eq::nonequivalent);
}

[編集] クラス std::partial_ordering

namespace std {
  class partial_ordering {
    int value; // exposition only
    bool is_ordered; // exposition only
    // exposition-only constructors
    explicit constexpr
    partial_ordering(eq v) noexcept : value(int(v)), is_ordered(true) {} // exposition only
    explicit constexpr
    partial_ordering(ord v) noexcept : value(int(v)), is_ordered(true) {} // exposition only
    explicit constexpr
    partial_ordering(ncmp v) noexcept : value(int(v)), is_ordered(false) {} // exposition only
    public:
    // valid values
    static const partial_ordering less;
    static const partial_ordering equivalent;
    static const partial_ordering greater;
    static const partial_ordering unordered;
    // conversion
    constexpr operator weak_equality() const noexcept;
    // comparisons
    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> (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 bool operator> (/*unspecified*/ , partial_ordering v) noexcept;
    friend constexpr bool operator>=(/*unspecified*/ , partial_ordering v) noexcept;
  };
  // valid values’ definitions
  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; // exposition only
    // exposition-only constructors
    explicit constexpr weak_ordering(eq v) noexcept : value(int(v)) {} // exposition only
    explicit constexpr weak_ordering(ord v) noexcept : value(int(v)) {} // exposition only
    public:
    // valid values
    static const weak_ordering less;
    static const weak_ordering equivalent;
    static const weak_ordering greater;
    // conversions
    constexpr operator weak_equality() const noexcept;
    constexpr operator partial_ordering() const noexcept;
    // comparisons
    friend constexpr bool operator==(weak_ordering v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator!=(weak_ordering v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator< (weak_ordering v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator<=(weak_ordering v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator> (weak_ordering v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator>=(weak_ordering v, /*unspecified*/ ) noexcept;
    friend constexpr bool operator==(/*unspecified*/ , weak_ordering v) noexcept;
    friend constexpr bool operator!=(/*unspecified*/ , weak_ordering v) noexcept;
    friend constexpr bool operator< (/*unspecified*/ , weak_ordering v) noexcept;
    friend constexpr bool operator<=(/*unspecified*/ , weak_ordering v) noexcept;
    friend constexpr bool operator> (/*unspecified*/ , weak_ordering v) noexcept;
    friend constexpr bool operator>=(/*unspecified*/ , weak_ordering v) noexcept;
  };
  // valid values’ definitions
  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; // exposition only
    // exposition-only constructors
    explicit constexpr strong_ordering(eq v) noexcept : value(int(v)) {} // exposition only
    explicit constexpr strong_ordering(ord v) noexcept : value(int(v)) {} // exposition only
    public:
    // valid values
    static const strong_ordering less;
    static const strong_ordering equal;
    static const strong_ordering equivalent;
    static const strong_ordering greater;
    // conversions
    constexpr operator weak_equality() const noexcept;
    constexpr operator strong_equality() const noexcept;
    constexpr operator partial_ordering() const noexcept;
    constexpr operator weak_ordering() const noexcept;
    // comparisons
    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> (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 bool operator> (/*unspecified*/ , strong_ordering v) noexcept;
    friend constexpr bool operator>=(/*unspecified*/ , strong_ordering v) noexcept;
  };
  // valid values’ definitions
  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);
}

[編集] 関連項目

三方比較演算子 (C++20)