## mismatch
## Prototype
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); ## Description
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: -
`InputIterator1` is a model of InputIterator. -
`InputIterator2` is a model of InputIterator. -
`InputIterator1` 's value type is a model of EqualityComparable. -
`InputIterator2` 's value type is a model of EqualityComparable. -
`InputIterator1` 's value type can be compared for equality with`InputIterator2` 's value type.
For the second version: -
`InputIterator1` is a model of InputIterator. -
`InputIterator2` is a model of InputIterator. -
`BinaryPredicate` is a model of BinaryPredicate. -
`InputIterator1` 's value type is convertible to`BinaryPredicate` 's first argument type. -
`InputIterator2` 's value type is convertible to`BinaryPredicate` 's second argument type.
## Preconditions-
`[first1, last1)` is a valid range. -
`[first2, first2 + (last2 - last1))` is a valid range.
## ComplexityLinear. At most ## 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; ## Notes## See also |