mismatch
PrototypeMismatch is an overloaded name; there are actually two mismatch functions. template <class InputIterator1, class InputIterator2> pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template <class InputIterator1, class InputIterator2, class BinaryPredicate> pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate binary_pred); DescriptionMismatch finds the first position where the two ranges [first1, last1) and [first2, first2 + (last1 - first1)) differ. The two versions of mismatch use different tests for whether elements differ.
The first version of
The second version of DefinitionDefined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.Requirements on typesFor the first version:
Preconditions
ComplexityLinear. At mostlast1 - first1 comparisons. Exampleint A1[] = { 3, 1, 4, 1, 5, 9, 3 }; int A2[] = { 3, 1, 4, 2, 8, 5, 7 }; const int N = sizeof(A1) / sizeof(int); pair<int*, int*> result = mismatch(A1, A1 + N, A2); cout << "The first mismatch is in position " << result.first - A1 << endl; cout << "Values are: " << *(result.first) << ", " << *(result.second) << endl; NotesSee alsoequal, search, find, find_if | |||||||

