1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <algorithm>
10 
11 // template<InputIterator Iter, class T>
12 //   requires HasEqualTo<Iter::value_type, T>
13 //   constexpr Iter   // constexpr after C++17
14 //   find(Iter first, Iter last, const T& value);
15 
16 #include <algorithm>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 #include "test_iterators.h"
21 
22 #if TEST_STD_VER > 17
test_constexpr()23 TEST_CONSTEXPR bool test_constexpr() {
24     int ia[] = {1, 3, 5, 2, 4, 6};
25     int ib[] = {1, 2, 3, 4, 5, 6};
26     return    (std::find(std::begin(ia), std::end(ia), 5) == ia+2)
27            && (std::find(std::begin(ib), std::end(ib), 9) == ib+6)
28            ;
29     }
30 #endif
31 
main(int,char **)32 int main(int, char**)
33 {
34     int ia[] = {0, 1, 2, 3, 4, 5};
35     const unsigned s = sizeof(ia)/sizeof(ia[0]);
36     input_iterator<const int*> r = std::find(input_iterator<const int*>(ia),
37                                              input_iterator<const int*>(ia+s), 3);
38     assert(*r == 3);
39     r = std::find(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), 10);
40     assert(r == input_iterator<const int*>(ia+s));
41 
42 #if TEST_STD_VER > 17
43     static_assert(test_constexpr());
44 #endif
45 
46   return 0;
47 }
48