find.pass.cpp 1011 B

12345678910111213141516171819202122232425262728293031
  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, class T>
  11. // requires HasEqualTo<Iter::value_type, T>
  12. // Iter
  13. // find(Iter first, Iter last, const T& value);
  14. #include <algorithm>
  15. #include <cassert>
  16. #include "test_iterators.h"
  17. int main()
  18. {
  19. int ia[] = {0, 1, 2, 3, 4, 5};
  20. const unsigned s = sizeof(ia)/sizeof(ia[0]);
  21. input_iterator<const int*> r = std::find(input_iterator<const int*>(ia),
  22. input_iterator<const int*>(ia+s), 3);
  23. assert(*r == 3);
  24. r = std::find(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), 10);
  25. assert(r == input_iterator<const int*>(ia+s));
  26. }