1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <map>
11
12 // class multimap
13
14 // iterator insert(const value_type& v);
15
16 #include <map>
17 #include <cassert>
18
19 #include "min_allocator.h"
20
main()21 int main()
22 {
23 {
24 typedef std::multimap<int, double> M;
25 typedef M::iterator R;
26 M m;
27 R r = m.insert(M::value_type(2, 2.5));
28 assert(r == m.begin());
29 assert(m.size() == 1);
30 assert(r->first == 2);
31 assert(r->second == 2.5);
32
33 r = m.insert(M::value_type(1, 1.5));
34 assert(r == m.begin());
35 assert(m.size() == 2);
36 assert(r->first == 1);
37 assert(r->second == 1.5);
38
39 r = m.insert(M::value_type(3, 3.5));
40 assert(r == prev(m.end()));
41 assert(m.size() == 3);
42 assert(r->first == 3);
43 assert(r->second == 3.5);
44
45 r = m.insert(M::value_type(3, 3.5));
46 assert(r == prev(m.end()));
47 assert(m.size() == 4);
48 assert(r->first == 3);
49 assert(r->second == 3.5);
50 }
51 #if __cplusplus >= 201103L
52 {
53 typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
54 typedef M::iterator R;
55 M m;
56 R r = m.insert(M::value_type(2, 2.5));
57 assert(r == m.begin());
58 assert(m.size() == 1);
59 assert(r->first == 2);
60 assert(r->second == 2.5);
61
62 r = m.insert(M::value_type(1, 1.5));
63 assert(r == m.begin());
64 assert(m.size() == 2);
65 assert(r->first == 1);
66 assert(r->second == 1.5);
67
68 r = m.insert(M::value_type(3, 3.5));
69 assert(r == prev(m.end()));
70 assert(m.size() == 3);
71 assert(r->first == 3);
72 assert(r->second == 3.5);
73
74 r = m.insert(M::value_type(3, 3.5));
75 assert(r == prev(m.end()));
76 assert(m.size() == 4);
77 assert(r->first == 3);
78 assert(r->second == 3.5);
79 }
80 #endif
81 }
82