adjacent_find_pred.pass.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. // <algorithm>
  10. // template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
  11. // requires CopyConstructible<Pred>
  12. // Iter
  13. // adjacent_find(Iter first, Iter last, Pred pred);
  14. #include <algorithm>
  15. #include <functional>
  16. #include <cassert>
  17. #include "test_iterators.h"
  18. int main()
  19. {
  20. int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
  21. const unsigned sa = sizeof(ia)/sizeof(ia[0]);
  22. assert(std::adjacent_find(forward_iterator<const int*>(ia),
  23. forward_iterator<const int*>(ia + sa),
  24. std::equal_to<int>()) ==
  25. forward_iterator<const int*>(ia+2));
  26. assert(std::adjacent_find(forward_iterator<const int*>(ia),
  27. forward_iterator<const int*>(ia),
  28. std::equal_to<int>()) ==
  29. forward_iterator<const int*>(ia));
  30. assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
  31. forward_iterator<const int*>(ia + sa),
  32. std::equal_to<int>()) ==
  33. forward_iterator<const int*>(ia+sa));
  34. }