equal_to
描述 (Description)
它是用于相等性比较的函数对象类和二进制函数对象类,其调用返回它的两个参数是否相等(由operator ==返回)。
声明 (Declaration)
以下是std :: equal_to的声明。
template <class T> struct equal_to;
C++11
template <class T> struct equal_to;
参数 (Parameters)
T - 它是函数调用的参数和返回类型的一种类型。
返回值 (Return Value)
没有
异常 (Exceptions)
noexcep - 它不会抛出任何异常。
例子 (Example)
在下面的例子中解释了std :: equal_to。
#include <iostream>
#include <utility>
#include <functional>
#include <algorithm>
int main () {
std::pair<int*,int*> ptiter;
int foo[]={10,20,30,40};
int bar[]={10,50,40,80};
ptiter = std::mismatch (foo, foo+5, bar, std::equal_to<int>());
std::cout << "First mismatching pair is: " << *ptiter.first;
std::cout << " and " << *ptiter.second << '\n';
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
First mismatching pair is: 20 and 50