cppreference.com > C++ Algorithms > adjacent_find adjacent_find Syntax:
      #include <algorithm>
      iterator adjacent_find( iterator start, iterator end );
      iterator adjacent_find( iterator start, iterator end, BinPred pr );
The adjacent_find() function searches between start and end for two consecutive identical elements. If the binary predicate pr is specified, then it is used to test whether two elements are the same or not. The return value is an iterator that points to the first of the two elements that are found. If no matching elements are found, the returned iterator points to end. For example, the following code creates a vector containing the integers between 0 and 10 with 7 appearing twice in a row. adjacent_find() is then used to find the location of the pair of 7's:
     vector<int> v1;
     for( int i = 0; i < 10; i++ ) {
       v1.push_back(i);
       // add a duplicate 7 into v1
       if( i == 7 ) {
         v1.push_back(i);

       }
     }

     vector<int>::iterator result;
     result = adjacent_find( v1.begin(), v1.end() );

     if( result == v1.end() ) {
       cout << "Did not find adjacent elements in v1" << endl;
     }

     else {
       cout << "Found matching adjacent elements starting at " << *result << endl;
     }
Related topics: find find_end find_first_of find_if unique unique_copy