1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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>
26 #include "test_macros.h"
27 #include "min_allocator.h"
32 typedef std::unordered_set
<int> C
;
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());
51 typedef std::unordered_set
<int> C
;
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());
69 #if TEST_STD_VER >= 11
71 typedef std::unordered_set
<int, std::hash
<int>,
72 std::equal_to
<int>, min_allocator
<int>> C
;
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());
91 typedef std::unordered_set
<int, std::hash
<int>,
92 std::equal_to
<int>, min_allocator
<int>> C
;
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());
111 #if TEST_STD_VER > 11
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
));