equal()
Returns true if the two sequences are equal for the number of elements contained within the first container. By default, the equality operator is used. Alternatively, a binary function object or pointer to function can be supplied.
#include <algorithm>
class EqualAndOdd{
public:
bool operator()( int v1, int v2 )
{ return ((v1==v2) && (v1%2)); }
};
int ia1[] = { 1,1,2,3,5,8,13 };
int ia2[] = { 1,1,2,3,5,8,13,21,34 };
res = equal( ia1, ia1+7, ia2 ); // true
res = equal( ia1, ia1+7, ia2, equalAndOdd() ); // false
|