template <class T> struct equal_to;
123
template <class T> struct equal_to : binary_function <T,T,bool> { bool operator() (const T& x, const T& y) const {return x==y;} };
123456
template <class T> struct equal_to { bool operator() (const T& x, const T& y) const {return x==y;} typedef T first_argument_type; typedef T second_argument_type; typedef bool result_type; };
operator()
x==y
123456789101112131415
// equal_to example #include <iostream> // std::cout #include <utility> // std::pair #include <functional> // std::equal_to #include <algorithm> // std::mismatch int main () { std::pair<int*,int*> ptiter; int foo[]={10,20,30,40,50}; int bar[]={10,20,40,80,160}; 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: 30 and 40