find_if_not.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
  11. // requires CopyConstructible<Pred>
  12. // Iter
  13. // find_if_not(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, 3, 4, 5};
  21. const unsigned s = sizeof(ia)/sizeof(ia[0]);
  22. input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
  23. input_iterator<const int*>(ia+s),
  24. std::bind2nd(std::not_equal_to<int>(), 3));
  25. assert(*r == 3);
  26. r = std::find_if_not(input_iterator<const int*>(ia),
  27. input_iterator<const int*>(ia+s),
  28. std::bind2nd(std::not_equal_to<int>(), 10));
  29. assert(r == input_iterator<const int*>(ia+s));
  30. }