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 | // <map> |
10 | |
11 | // class multimap |
12 | |
13 | // void clear() noexcept; |
14 | |
15 | #include <map> |
16 | #include <cassert> |
17 | |
18 | #include "test_macros.h" |
19 | #include "min_allocator.h" |
20 | |
21 | int main(int, char**) |
22 | { |
23 | { |
24 | typedef std::multimap<int, double> M; |
25 | typedef std::pair<int, double> P; |
26 | P ar[] = |
27 | { |
28 | P(1, 1.5), |
29 | P(2, 2.5), |
30 | P(3, 3.5), |
31 | P(4, 4.5), |
32 | P(5, 5.5), |
33 | P(6, 6.5), |
34 | P(7, 7.5), |
35 | P(8, 8.5), |
36 | }; |
37 | M m(ar, ar + sizeof(ar)/sizeof(ar[0])); |
38 | assert(m.size() == 8); |
39 | ASSERT_NOEXCEPT(m.clear()); |
40 | m.clear(); |
41 | assert(m.size() == 0); |
42 | } |
43 | #if TEST_STD_VER >= 11 |
44 | { |
45 | typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; |
46 | typedef std::pair<int, double> P; |
47 | P ar[] = |
48 | { |
49 | P(1, 1.5), |
50 | P(2, 2.5), |
51 | P(3, 3.5), |
52 | P(4, 4.5), |
53 | P(5, 5.5), |
54 | P(6, 6.5), |
55 | P(7, 7.5), |
56 | P(8, 8.5), |
57 | }; |
58 | M m(ar, ar + sizeof(ar)/sizeof(ar[0])); |
59 | assert(m.size() == 8); |
60 | ASSERT_NOEXCEPT(m.clear()); |
61 | m.clear(); |
62 | assert(m.size() == 0); |
63 | } |
64 | #endif |
65 | |
66 | return 0; |
67 | } |
68 | |