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 Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12 // class Alloc = allocator<pair<const Key, T>>>
13 // class unordered_map
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_map>
27 #include "test_macros.h"
28 #include "min_allocator.h"
33 typedef std::unordered_map
<int, std::string
> C
;
34 typedef std::pair
<int, std::string
> P
;
44 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
45 assert(c
.bucket_count() >= 5);
46 assert(c
.size() == 4);
47 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
48 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
52 typedef std::unordered_map
<int, std::string
> C
;
53 typedef std::pair
<int, std::string
> P
;
63 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
64 assert(c
.bucket_count() >= 5);
65 assert(c
.size() == 4);
66 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
67 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
70 #if TEST_STD_VER >= 11
72 typedef std::unordered_map
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
73 min_allocator
<std::pair
<const int, std::string
>>> C
;
74 typedef std::pair
<int, std::string
> P
;
84 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
85 assert(c
.bucket_count() >= 5);
86 assert(c
.size() == 4);
87 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
88 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
92 typedef std::unordered_map
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
93 min_allocator
<std::pair
<const int, std::string
>>> C
;
94 typedef std::pair
<int, std::string
> P
;
104 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
105 assert(c
.bucket_count() >= 5);
106 assert(c
.size() == 4);
107 assert(static_cast<std::size_t>(std::distance(c
.begin(), c
.end())) == c
.size());
108 assert(static_cast<std::size_t>(std::distance(c
.cbegin(), c
.cend())) == c
.size());
112 #if TEST_STD_VER > 11
114 typedef std::unordered_map
<int,double> C
;
115 C::iterator ii1
{}, ii2
{};
116 C::iterator ii4
= ii1
;
117 C::const_iterator cii
{};
118 assert ( ii1
== ii2
);
119 assert ( ii1
== ii4
);
121 assert (!(ii1
!= ii2
));
123 assert ( (ii1
== cii
));
124 assert ( (cii
== ii1
));
125 assert (!(ii1
!= cii
));
126 assert (!(cii
!= ii1
));