In the first version, the comparison is performed by applying the == comparison operator between the elements being iterated and value. In the second version, comp is applied to these, and a return value of true (or non-zero) is interpreted as an equivalence.
The behavior of this function template is equivalent to:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Parameters
- first, last
- Forward iterators to the initial and final positions of the searched sequence. The range used is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
- count
- Minimum number of successive elements meeting the predicate to be considered a match.
Its type is an integral type or some other type convertible to it. - value
- Individual value to be compared, or to be used as argument for pred (in the second version).
Its type has to support the appropriate equality comparison, for the first version. - 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
An iterator to the first element of the first occurrence of the succession of count equal values in [first,last).If the sequence is not found, the function returns last.
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 34 |
|
Output:
Two 30s found at position 2 Two 10s found at position 5 |
Complexity
At most, performs as many comparisons or applications of pred as count*(distance(first,last)-count).See also
| search | Find subsequence in range (function template) |
| find_first_of | Find element from set in range (function template) |
| find | Find value in range (function template) |
| equal | Test whether the elements in two ranges are equal (function template) |
