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_iterator position, const value_type& v);
15 
16 #include <map>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 #include "min_allocator.h"
21 
22 template <class Container>
do_insert_hint_test()23 void do_insert_hint_test()
24 {
25     typedef Container M;
26     typedef typename M::iterator R;
27     typedef typename M::value_type VT;
28     M m;
29     const VT v1(2, 2.5);
30     R r = m.insert(m.end(), v1);
31     assert(r == m.begin());
32     assert(m.size() == 1);
33     assert(r->first == 2);
34     assert(r->second == 2.5);
35 
36     const VT v2(1, 1.5);
37     r = m.insert(m.end(), v2);
38     assert(r == m.begin());
39     assert(m.size() == 2);
40     assert(r->first == 1);
41     assert(r->second == 1.5);
42 
43     const VT v3(3, 3.5);
44     r = m.insert(m.end(), v3);
45     assert(r == prev(m.end()));
46     assert(m.size() == 3);
47     assert(r->first == 3);
48     assert(r->second == 3.5);
49 
50     const VT v4(3, 4.5);
51     r = m.insert(prev(m.end()), v4);
52     assert(r == prev(m.end(), 2));
53     assert(m.size() == 4);
54     assert(r->first == 3);
55     assert(r->second == 4.5);
56 }
57 
main()58 int main()
59 {
60     do_insert_hint_test<std::multimap<int, double> >();
61 #if TEST_STD_VER >= 11
62     {
63         typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
64         do_insert_hint_test<M>();
65     }
66 #endif
67 }
68