Standard C++ Library Class Reference

// p1 will contain two iterators that point to the
// first pair of elements that are different between
// the two vectors
pair<iterator, iterator> p1 = mismatch(vi1.begin(), vi1.end(),
vi2.begin());
// find the first two elements such that an element in the
// first vector is greater than the element in the second
// vector.
pair<iterator, iterator> p2 = mismatch(vi1.begin(), vi1.end(),
vi2.begin(),
less_equal<int>());
// Output results
cout << *p1.first << ", " << *p1.second << endl;
cout << *p2.first << ", " << *p2.second << endl;
return 0;
}
Output :
2, 3
3, 2
Warning
If your compiler does not support default template parameters, then you need to always supply
the Allocator template argument. For instance, you will need to write :
vector<int, allocator>
instead of:
vector<int>