std::equal_to
來自 cppreference.com
定義於標頭檔案 <functional> |
||
template< class T > struct equal_to; |
(until C++14) | |
template< class T = void > struct equal_to; |
(C++14 起) | |
用於執行比較的函式物件。除非特化,否則對型別 T
呼叫 operator==。
目錄 |
[編輯] 特化
當未指定
|
(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; |
(C++14 起為 constexpr) | |
檢查 lhs 是否“等於” rhs。
引數
lhs, rhs | - | 要比較的值 |
返回值
如果 lhs == rhs 為 true,否則為 false。
[編輯] 異常
可能丟擲實現定義的異常。
可能的實現
constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs == rhs; } |
[編輯] 參閱
判斷兩組元素是否相同 (函式模板) | |
實現 x != y 的函式物件 (類模板) | |
實現 x < y 的函式物件 (類模板) | |
(C++20) |
實現 x == y 的受限函式物件 (類) |