Namespaces
Variants

std:: equal_to

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
ヘッダーで定義 <functional>
template < class T >
struct equal_to ;
(C++14まで)
template < class T = void >
struct equal_to ;
(C++14から)

比較を実行するための関数オブジェクト。特殊化されていない限り、型 T に対して operator == を呼び出します。

目次

特殊化

標準ライブラリは、 T が指定されていない場合の std::equal_to の特殊化を提供しており、 パラメータ型と戻り値型が推論されるようになります。

x == y を実装する関数オブジェクトで、 パラメータ型と戻り値型を推論する
(クラステンプレートの特殊化)
(C++14以降)

メンバー型

定義
result_type (C++17で非推奨) (C++20で削除) bool
first_argument_type (C++17で非推奨) (C++20で削除) T
second_argument_type (C++17で非推奨) (C++20で削除) T

これらのメンバ型は、公開継承によって std:: binary_function < T, T, bool > から取得されます。

(C++11まで)

メンバー関数

operator()
引数が 等しい かどうかをチェックする
(公開メンバ関数)

std::equal_to:: operator()

bool operator ( ) ( const T & lhs, const T & rhs ) const ;
(constexpr since C++14)

lhs rhs 等しい かどうかをチェックします。

パラメータ

lhs, rhs - 比較する値

戻り値

true の場合、 lhs == rhs を意味し、 false の場合はそれ以外を意味します。

例外

実装定義の例外をスローする可能性があります。

実装例

constexpr bool operator()(const T& lhs, const T& rhs) const 
{
    return lhs == rhs;
}

関連項目

2つの要素の集合が同じかどうかを判定する
(関数テンプレート)
x ! = y を実装する関数オブジェクト
(クラステンプレート)
x < y を実装する関数オブジェクト
(クラステンプレート)
x == y を実装する制約付き関数オブジェクト
(クラス)