## adjacent_find
## Prototype
template <class ForwardIterator> ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last); template <class ForwardIterator, class BinaryPredicate> ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate binary_pred); ## DescriptionThe 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: -
`ForwardIterator` is a model of ForwardIterator. -
`ForwardIterator` 's value type is EqualityComparable.
For the second version: -
`ForwardIterator` is a model of ForwardIterator. -
`ForwardIterator` 's value type is convertible to`BinaryPredicate` 's first argument type and to its second argument type.
## Preconditions-
`[first, last)` is a valid range.
## ComplexityLinear. If ## ExampleFind the first element that is greater than its successor. int A[] = {1, 2, 3, 4, 6, 5, 7, 8}; const int N = sizeof(A) / sizeof(int); const int* p = adjacent_find(A, A + N, greater<int>()); cout << "Element " << p - A << " is out of order: " << *p << " > " << *(p + 1) << "." << endl; ## Notes## See also |