The elements are compared by either applying the == comparison operator to each pair of corresponding elements, or the template parameter comp (for the second version).
The function returns a pair of iterators to the first element in each range which differs in both sequences.
The behavior of this function template is equivalent to:
| 1 2 3 4 5 6 7 8 9 10 11 12 |
|
Parameters
- first1, last1
- Forward iterators to the initial and final positions of the first sequence. The range used is [first1,last1), which contains all the elements between first1 and last1, including the element pointed by first1 but not the element pointed by last1.
- first2
- Forward iterator to the initial position of the second sequence. Up to as many elements as in the range [first1,last1) can be accessed by the function.
- pred
- Binary predicate taking two elements as argument (one of each of the two sequences), and returning the result of the comparison between them, with true (non-zero) meaning that they are to be considered equal, and false (zero) that they are not-equal. This can either be a pointer to a function or an object whose class overloads operator().
Return value
A pair, where its members first and second point to the first element in both sequences that did not compare equal to each other.If the elements compared in both sequences have all matched, the function returns a pair with first set to last1 and second set to the element in that same relative position in the second sequence.
If none matched, it returns make_pair(first1,first2).
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Output:
First mismatching elements: 30 and 80 Second mismatching elements: 40 and 320 |
Complexity
At most, performs as many comparisons or applications of pred as the number of elements in the range [first1,last1).See also
| find_first_of | Find element from set in range (function template) |
| find_end | Find last subsequence in range (function template) |
| search | Find subsequence in range (function template) |
| equal | Test whether the elements in two ranges are equal (function template) |
