[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / algorithms / alg.nonmodifying / alg.equal / equal.pass.cpp
blobafd57491a40212cc6be92122329fb05f6899c8a8
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<InputIterator Iter1, InputIterator Iter2>
12 // requires HasEqualTo<Iter1::value_type, Iter2::value_type>
13 // constexpr bool // constexpr after c++17
14 // equal(Iter1 first1, Iter1 last1, Iter2 first2);
16 // Introduced in C++14:
17 // template<InputIterator Iter1, InputIterator Iter2>
18 // constexpr bool // constexpr after c++17
19 // equal(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
21 #include <algorithm>
22 #include <cassert>
24 #include "test_macros.h"
25 #include "test_iterators.h"
27 #if TEST_STD_VER > 17
28 TEST_CONSTEXPR bool test_constexpr() {
29 int ia[] = {1, 3, 6, 7};
30 int ib[] = {1, 3};
31 int ic[] = {1, 3, 5, 7};
32 typedef input_iterator<int*> II;
33 typedef bidirectional_iterator<int*> BI;
35 return !std::equal(std::begin(ia), std::end(ia), std::begin(ic))
36 && !std::equal(std::begin(ia), std::end(ia), std::begin(ic), std::end(ic))
37 && std::equal(std::begin(ib), std::end(ib), std::begin(ic))
38 && !std::equal(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic))
40 && std::equal(II(std::begin(ib)), II(std::end(ib)), II(std::begin(ic)))
41 && !std::equal(BI(std::begin(ib)), BI(std::end(ib)), BI(std::begin(ic)), BI(std::end(ic)))
44 #endif
47 int main(int, char**)
49 int ia[] = {0, 1, 2, 3, 4, 5};
50 const unsigned s = sizeof(ia)/sizeof(ia[0]);
51 int ib[s] = {0, 1, 2, 5, 4, 5};
52 assert(std::equal(input_iterator<const int*>(ia),
53 input_iterator<const int*>(ia+s),
54 input_iterator<const int*>(ia)));
55 #if TEST_STD_VER >= 14
56 assert(std::equal(input_iterator<const int*>(ia),
57 input_iterator<const int*>(ia+s),
58 input_iterator<const int*>(ia),
59 input_iterator<const int*>(ia+s)));
60 assert(std::equal(random_access_iterator<const int*>(ia),
61 random_access_iterator<const int*>(ia+s),
62 random_access_iterator<const int*>(ia),
63 random_access_iterator<const int*>(ia+s)));
64 #endif
65 assert(!std::equal(input_iterator<const int*>(ia),
66 input_iterator<const int*>(ia+s),
67 input_iterator<const int*>(ib)));
68 #if TEST_STD_VER >= 14
69 assert(!std::equal(input_iterator<const int*>(ia),
70 input_iterator<const int*>(ia+s),
71 input_iterator<const int*>(ib),
72 input_iterator<const int*>(ib+s)));
73 assert(!std::equal(random_access_iterator<const int*>(ia),
74 random_access_iterator<const int*>(ia+s),
75 random_access_iterator<const int*>(ib),
76 random_access_iterator<const int*>(ib+s)));
77 assert(!std::equal(input_iterator<const int*>(ia),
78 input_iterator<const int*>(ia+s),
79 input_iterator<const int*>(ia),
80 input_iterator<const int*>(ia+s-1)));
81 assert(!std::equal(random_access_iterator<const int*>(ia),
82 random_access_iterator<const int*>(ia+s),
83 random_access_iterator<const int*>(ia),
84 random_access_iterator<const int*>(ia+s-1)));
86 #endif
88 #if TEST_STD_VER > 17
89 static_assert(test_constexpr());
90 #endif
92 return 0;