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_map> |
10 | |
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 |
14 | |
15 | // void clear() noexcept; |
16 | |
17 | #include <unordered_map> |
18 | #include <string> |
19 | #include <cassert> |
20 | |
21 | #include "test_macros.h" |
22 | #include "min_allocator.h" |
23 | |
24 | int main(int, char**) |
25 | { |
26 | { |
27 | typedef std::unordered_map<int, std::string> C; |
28 | typedef std::pair<int, std::string> P; |
29 | P a[] = |
30 | { |
31 | P(1, "one" ), |
32 | P(2, "two" ), |
33 | P(3, "three" ), |
34 | P(4, "four" ), |
35 | P(1, "four" ), |
36 | P(2, "four" ), |
37 | }; |
38 | C c(a, a + sizeof(a)/sizeof(a[0])); |
39 | ASSERT_NOEXCEPT(c.clear()); |
40 | c.clear(); |
41 | assert(c.size() == 0); |
42 | } |
43 | #if TEST_STD_VER >= 11 |
44 | { |
45 | typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, |
46 | min_allocator<std::pair<const int, std::string>>> C; |
47 | typedef std::pair<int, std::string> P; |
48 | P a[] = |
49 | { |
50 | P(1, "one" ), |
51 | P(2, "two" ), |
52 | P(3, "three" ), |
53 | P(4, "four" ), |
54 | P(1, "four" ), |
55 | P(2, "four" ), |
56 | }; |
57 | C c(a, a + sizeof(a)/sizeof(a[0])); |
58 | ASSERT_NOEXCEPT(c.clear()); |
59 | c.clear(); |
60 | assert(c.size() == 0); |
61 | } |
62 | #endif |
63 | |
64 | return 0; |
65 | } |
66 | |