• 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(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 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
25     typedef std::pair<const int, double> V;
26     {
27         typedef test_compare<std::less<int> > C;
28         typedef test_allocator<V> A;
29         std::multimap<int, double, C, A> mo(C(5), A(7));
30         std::multimap<int, double, C, A> m = std::move(mo);
31         assert(m.get_allocator() == A(7));
32         assert(m.key_comp() == C(5));
33         assert(m.size() == 0);
34         assert(distance(m.begin(), m.end()) == 0);
35 
36         assert(mo.get_allocator() == A(7));
37         assert(mo.key_comp() == C(5));
38         assert(mo.size() == 0);
39         assert(distance(mo.begin(), mo.end()) == 0);
40     }
41     {
42         V ar[] =
43         {
44             V(1, 1),
45             V(1, 1.5),
46             V(1, 2),
47             V(2, 1),
48             V(2, 1.5),
49             V(2, 2),
50             V(3, 1),
51             V(3, 1.5),
52             V(3, 2),
53         };
54         typedef test_compare<std::less<int> > C;
55         typedef test_allocator<V> A;
56         std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
57         std::multimap<int, double, C, A> m = std::move(mo);
58         assert(m.get_allocator() == A(7));
59         assert(m.key_comp() == C(5));
60         assert(m.size() == 9);
61         assert(distance(m.begin(), m.end()) == 9);
62         assert(*m.begin() == V(1, 1));
63         assert(*next(m.begin()) == V(1, 1.5));
64         assert(*next(m.begin(), 2) == V(1, 2));
65         assert(*next(m.begin(), 3) == V(2, 1));
66         assert(*next(m.begin(), 4) == V(2, 1.5));
67         assert(*next(m.begin(), 5) == V(2, 2));
68         assert(*next(m.begin(), 6) == V(3, 1));
69         assert(*next(m.begin(), 7) == V(3, 1.5));
70         assert(*next(m.begin(), 8) == V(3, 2));
71 
72         assert(mo.get_allocator() == A(7));
73         assert(mo.key_comp() == C(5));
74         assert(mo.size() == 0);
75         assert(distance(mo.begin(), mo.end()) == 0);
76     }
77 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
78 }
79