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 //===----------------------------------------------------------------------===//
13 // size_type erase(const key_type& k);
18 #include "test_macros.h"
19 #include "min_allocator.h"
24 typedef std::multimap
<int, double> M
;
25 typedef std::pair
<int, double> P
;
26 typedef M::size_type I
;
39 M
m(ar
, ar
+ sizeof(ar
)/sizeof(ar
[0]));
40 assert(m
.size() == 9);
42 assert(m
.size() == 6);
44 assert(std::next(m
.begin(), 0)->first
== 1);
45 assert(std::next(m
.begin(), 0)->second
== 1);
46 assert(std::next(m
.begin(), 1)->first
== 1);
47 assert(std::next(m
.begin(), 1)->second
== 1.5);
48 assert(std::next(m
.begin(), 2)->first
== 1);
49 assert(std::next(m
.begin(), 2)->second
== 2);
50 assert(std::next(m
.begin(), 3)->first
== 3);
51 assert(std::next(m
.begin(), 3)->second
== 1);
52 assert(std::next(m
.begin(), 4)->first
== 3);
53 assert(std::next(m
.begin(), 4)->second
== 1.5);
54 assert(std::next(m
.begin(), 5)->first
== 3);
55 assert(std::next(m
.begin(), 5)->second
== 2);
58 assert(m
.size() == 6);
60 assert(std::next(m
.begin(), 0)->first
== 1);
61 assert(std::next(m
.begin(), 0)->second
== 1);
62 assert(std::next(m
.begin(), 1)->first
== 1);
63 assert(std::next(m
.begin(), 1)->second
== 1.5);
64 assert(std::next(m
.begin(), 2)->first
== 1);
65 assert(std::next(m
.begin(), 2)->second
== 2);
66 assert(std::next(m
.begin(), 3)->first
== 3);
67 assert(std::next(m
.begin(), 3)->second
== 1);
68 assert(std::next(m
.begin(), 4)->first
== 3);
69 assert(std::next(m
.begin(), 4)->second
== 1.5);
70 assert(std::next(m
.begin(), 5)->first
== 3);
71 assert(std::next(m
.begin(), 5)->second
== 2);
75 assert(m
.size() == 3);
76 assert(std::next(m
.begin(), 0)->first
== 1);
77 assert(std::next(m
.begin(), 0)->second
== 1);
78 assert(std::next(m
.begin(), 1)->first
== 1);
79 assert(std::next(m
.begin(), 1)->second
== 1.5);
80 assert(std::next(m
.begin(), 2)->first
== 1);
81 assert(std::next(m
.begin(), 2)->second
== 2);
84 assert(m
.size() == 0);
87 #if TEST_STD_VER >= 11
89 typedef std::multimap
<int, double, std::less
<int>, min_allocator
<std::pair
<const int, double>>> M
;
90 typedef std::pair
<int, double> P
;
91 typedef M::size_type I
;
104 M
m(ar
, ar
+ sizeof(ar
)/sizeof(ar
[0]));
105 assert(m
.size() == 9);
107 assert(m
.size() == 6);
109 assert(std::next(m
.begin(), 0)->first
== 1);
110 assert(std::next(m
.begin(), 0)->second
== 1);
111 assert(std::next(m
.begin(), 1)->first
== 1);
112 assert(std::next(m
.begin(), 1)->second
== 1.5);
113 assert(std::next(m
.begin(), 2)->first
== 1);
114 assert(std::next(m
.begin(), 2)->second
== 2);
115 assert(std::next(m
.begin(), 3)->first
== 3);
116 assert(std::next(m
.begin(), 3)->second
== 1);
117 assert(std::next(m
.begin(), 4)->first
== 3);
118 assert(std::next(m
.begin(), 4)->second
== 1.5);
119 assert(std::next(m
.begin(), 5)->first
== 3);
120 assert(std::next(m
.begin(), 5)->second
== 2);
123 assert(m
.size() == 6);
125 assert(std::next(m
.begin(), 0)->first
== 1);
126 assert(std::next(m
.begin(), 0)->second
== 1);
127 assert(std::next(m
.begin(), 1)->first
== 1);
128 assert(std::next(m
.begin(), 1)->second
== 1.5);
129 assert(std::next(m
.begin(), 2)->first
== 1);
130 assert(std::next(m
.begin(), 2)->second
== 2);
131 assert(std::next(m
.begin(), 3)->first
== 3);
132 assert(std::next(m
.begin(), 3)->second
== 1);
133 assert(std::next(m
.begin(), 4)->first
== 3);
134 assert(std::next(m
.begin(), 4)->second
== 1.5);
135 assert(std::next(m
.begin(), 5)->first
== 3);
136 assert(std::next(m
.begin(), 5)->second
== 2);
140 assert(m
.size() == 3);
141 assert(std::next(m
.begin(), 0)->first
== 1);
142 assert(std::next(m
.begin(), 0)->second
== 1);
143 assert(std::next(m
.begin(), 1)->first
== 1);
144 assert(std::next(m
.begin(), 1)->second
== 1.5);
145 assert(std::next(m
.begin(), 2)->first
== 1);
146 assert(std::next(m
.begin(), 2)->second
== 2);
149 assert(m
.size() == 0);