• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<InputIterator Iter1, ForwardIterator Iter2,
13 //          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
14 //   requires CopyConstructible<Pred>
15 //   Iter1
16 //   find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
17 
18 #include <algorithm>
19 #include <functional>
20 #include <cassert>
21 
22 #include "test_iterators.h"
23 
main()24 int main()
25 {
26     int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
27     const unsigned sa = sizeof(ia)/sizeof(ia[0]);
28     int ib[] = {1, 3, 5, 7};
29     const unsigned sb = sizeof(ib)/sizeof(ib[0]);
30     assert(std::find_first_of(input_iterator<const int*>(ia),
31                               input_iterator<const int*>(ia + sa),
32                               forward_iterator<const int*>(ib),
33                               forward_iterator<const int*>(ib + sb),
34                               std::equal_to<int>()) ==
35                               input_iterator<const int*>(ia+1));
36     int ic[] = {7};
37     assert(std::find_first_of(input_iterator<const int*>(ia),
38                               input_iterator<const int*>(ia + sa),
39                               forward_iterator<const int*>(ic),
40                               forward_iterator<const int*>(ic + 1),
41                               std::equal_to<int>()) ==
42                               input_iterator<const int*>(ia+sa));
43     assert(std::find_first_of(input_iterator<const int*>(ia),
44                               input_iterator<const int*>(ia + sa),
45                               forward_iterator<const int*>(ic),
46                               forward_iterator<const int*>(ic),
47                               std::equal_to<int>()) ==
48                               input_iterator<const int*>(ia+sa));
49     assert(std::find_first_of(input_iterator<const int*>(ia),
50                               input_iterator<const int*>(ia),
51                               forward_iterator<const int*>(ic),
52                               forward_iterator<const int*>(ic+1),
53                               std::equal_to<int>()) ==
54                               input_iterator<const int*>(ia));
55 }
56