• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // multimap(const multimap& m);
15 
16 #include <map>
17 #include <cassert>
18 
19 #include "../../../test_compare.h"
20 #include "../../../test_allocator.h"
21 
main()22 int main()
23 {
24     {
25         typedef std::pair<const int, double> V;
26         V ar[] =
27         {
28             V(1, 1),
29             V(1, 1.5),
30             V(1, 2),
31             V(2, 1),
32             V(2, 1.5),
33             V(2, 2),
34             V(3, 1),
35             V(3, 1.5),
36             V(3, 2),
37         };
38         typedef test_compare<std::less<int> > C;
39         typedef test_allocator<V> A;
40         std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
41         std::multimap<int, double, C, A> m = mo;
42         assert(m == mo);
43         assert(m.get_allocator() == A(7));
44         assert(m.key_comp() == C(5));
45 
46         assert(mo.get_allocator() == A(7));
47         assert(mo.key_comp() == C(5));
48     }
49 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
50     {
51         typedef std::pair<const int, double> V;
52         V ar[] =
53         {
54             V(1, 1),
55             V(1, 1.5),
56             V(1, 2),
57             V(2, 1),
58             V(2, 1.5),
59             V(2, 2),
60             V(3, 1),
61             V(3, 1.5),
62             V(3, 2),
63         };
64         typedef test_compare<std::less<int> > C;
65         typedef other_allocator<V> A;
66         std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
67         std::multimap<int, double, C, A> m = mo;
68         assert(m == mo);
69         assert(m.get_allocator() == A(-2));
70         assert(m.key_comp() == C(5));
71 
72         assert(mo.get_allocator() == A(7));
73         assert(mo.key_comp() == C(5));
74     }
75 #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
76 }
77