[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / algorithms / alg.nonmodifying / alg.adjacent.find / adjacent_find.pass.cpp
blob6d57c5869ab704e7f23605c29c6d48e17564623a
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 //===----------------------------------------------------------------------===//
9 // <algorithm>
11 // template<ForwardIterator Iter>
12 // requires EqualityComparable<Iter::value_type>
13 // constexpr Iter // constexpr after C++17
14 // adjacent_find(Iter first, Iter last);
16 #include <algorithm>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "test_iterators.h"
22 #if TEST_STD_VER > 17
23 TEST_CONSTEXPR bool test_constexpr() {
24 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
25 int ib[] = {0, 1, 2, 7, 0, 1, 2, 3};
27 return (std::adjacent_find(std::begin(ia), std::end(ia)) == ia+2)
28 && (std::adjacent_find(std::begin(ib), std::end(ib)) == std::end(ib))
31 #endif
33 int main(int, char**)
35 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
36 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
37 assert(std::adjacent_find(forward_iterator<const int*>(ia),
38 forward_iterator<const int*>(ia + sa)) ==
39 forward_iterator<const int*>(ia+2));
40 assert(std::adjacent_find(forward_iterator<const int*>(ia),
41 forward_iterator<const int*>(ia)) ==
42 forward_iterator<const int*>(ia));
43 assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
44 forward_iterator<const int*>(ia + sa)) ==
45 forward_iterator<const int*>(ia+sa));
47 #if TEST_STD_VER > 17
48 static_assert(test_constexpr());
49 #endif
51 return 0;