[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / iterators.pass.cpp
blobeb8459101b2a289bb7e8729c7afa71bc98cb4c2c
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 // <unordered_set>
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
15 // iterator begin() {return __table_.begin();}
16 // iterator end() {return __table_.end();}
17 // const_iterator begin() const {return __table_.begin();}
18 // const_iterator end() const {return __table_.end();}
19 // const_iterator cbegin() const {return __table_.begin();}
20 // const_iterator cend() const {return __table_.end();}
22 #include <unordered_set>
23 #include <cassert>
24 #include <cstddef>
26 #include "test_macros.h"
27 #include "min_allocator.h"
29 int main(int, char**)
32 typedef std::unordered_set<int> C;
33 typedef int P;
34 P a[] =
36 P(1),
37 P(2),
38 P(3),
39 P(4),
40 P(1),
41 P(2)
43 C c(a, a + sizeof(a)/sizeof(a[0]));
44 assert(c.bucket_count() >= 5);
45 assert(c.size() == 4);
46 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
47 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
48 C::iterator i;
51 typedef std::unordered_set<int> C;
52 typedef int P;
53 P a[] =
55 P(1),
56 P(2),
57 P(3),
58 P(4),
59 P(1),
60 P(2)
62 const C c(a, a + sizeof(a)/sizeof(a[0]));
63 assert(c.bucket_count() >= 5);
64 assert(c.size() == 4);
65 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
66 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
67 C::const_iterator i;
69 #if TEST_STD_VER >= 11
71 typedef std::unordered_set<int, std::hash<int>,
72 std::equal_to<int>, min_allocator<int>> C;
73 typedef int P;
74 P a[] =
76 P(1),
77 P(2),
78 P(3),
79 P(4),
80 P(1),
81 P(2)
83 C c(a, a + sizeof(a)/sizeof(a[0]));
84 assert(c.bucket_count() >= 5);
85 assert(c.size() == 4);
86 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
87 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
88 C::iterator i;
91 typedef std::unordered_set<int, std::hash<int>,
92 std::equal_to<int>, min_allocator<int>> C;
93 typedef int P;
94 P a[] =
96 P(1),
97 P(2),
98 P(3),
99 P(4),
100 P(1),
101 P(2)
103 const C c(a, a + sizeof(a)/sizeof(a[0]));
104 assert(c.bucket_count() >= 5);
105 assert(c.size() == 4);
106 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
107 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
108 C::const_iterator i;
110 #endif
111 #if TEST_STD_VER > 11
112 { // N3644 testing
113 typedef std::unordered_set<int> C;
114 C::iterator ii1{}, ii2{};
115 C::iterator ii4 = ii1;
116 C::const_iterator cii{};
117 assert ( ii1 == ii2 );
118 assert ( ii1 == ii4 );
120 assert (!(ii1 != ii2 ));
122 assert ( (ii1 == cii ));
123 assert ( (cii == ii1 ));
124 assert (!(ii1 != cii ));
125 assert (!(cii != ii1 ));
127 #endif
129 return 0;