1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <algorithm> 11 12 // template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred> 13 // requires CopyConstructible<Pred> 14 // Iter 15 // adjacent_find(Iter first, Iter last, Pred pred); 16 17 #include <algorithm> 18 #include <functional> 19 #include <cassert> 20 21 #include "test_iterators.h" 22 23 int main() 24 { 25 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; 26 const unsigned sa = sizeof(ia)/sizeof(ia[0]); 27 assert(std::adjacent_find(forward_iterator<const int*>(ia), 28 forward_iterator<const int*>(ia + sa), 29 std::equal_to<int>()) == 30 forward_iterator<const int*>(ia+2)); 31 assert(std::adjacent_find(forward_iterator<const int*>(ia), 32 forward_iterator<const int*>(ia), 33 std::equal_to<int>()) == 34 forward_iterator<const int*>(ia)); 35 assert(std::adjacent_find(forward_iterator<const int*>(ia+3), 36 forward_iterator<const int*>(ia + sa), 37 std::equal_to<int>()) == 38 forward_iterator<const int*>(ia+sa)); 39 } 40