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 | // <unordered_set> |
10 | |
11 | // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, |
12 | // class Alloc = allocator<Value>> |
13 | // class unordered_set |
14 | |
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();} |
21 | |
22 | #include <unordered_set> |
23 | #include <cassert> |
24 | |
25 | int main(int, char**) |
26 | { |
27 | { |
28 | typedef std::unordered_set<int> C; |
29 | typedef int P; |
30 | P a[] = |
31 | { |
32 | P(1), |
33 | P(2), |
34 | P(3), |
35 | P(4), |
36 | P(1), |
37 | P(2) |
38 | }; |
39 | C c(a, a + sizeof(a)/sizeof(a[0])); |
40 | assert(c.bucket_count() >= 5); |
41 | assert(c.size() == 6); |
42 | assert(std::distance(c.begin(), c.end()) == c.size()); |
43 | assert(std::distance(c.cbegin(), c.cend()) == c.size()); |
44 | C::iterator i = c.begin(); |
45 | assert(*i == 1); |
46 | *i = 2; |
47 | } |
48 | { |
49 | typedef std::unordered_set<int> C; |
50 | typedef int P; |
51 | P a[] = |
52 | { |
53 | P(1), |
54 | P(2), |
55 | P(3), |
56 | P(4), |
57 | P(1), |
58 | P(2) |
59 | }; |
60 | const C c(a, a + sizeof(a)/sizeof(a[0])); |
61 | assert(c.bucket_count() >= 5); |
62 | assert(c.size() == 6); |
63 | assert(std::distance(c.begin(), c.end()) == c.size()); |
64 | assert(std::distance(c.cbegin(), c.cend()) == c.size()); |
65 | } |
66 | |
67 | return 0; |
68 | } |
69 | |