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#include "min_allocator.h"
22
23int main()
24{
25    {
26        typedef std::pair<const int, double> V;
27        V ar[] =
28        {
29            V(1, 1),
30            V(1, 1.5),
31            V(1, 2),
32            V(2, 1),
33            V(2, 1.5),
34            V(2, 2),
35            V(3, 1),
36            V(3, 1.5),
37            V(3, 2),
38        };
39        typedef test_compare<std::less<int> > C;
40        typedef test_allocator<V> A;
41        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
42        std::multimap<int, double, C, A> m = mo;
43        assert(m == mo);
44        assert(m.get_allocator() == A(7));
45        assert(m.key_comp() == C(5));
46
47        assert(mo.get_allocator() == A(7));
48        assert(mo.key_comp() == C(5));
49    }
50#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
51    {
52        typedef std::pair<const int, double> V;
53        V ar[] =
54        {
55            V(1, 1),
56            V(1, 1.5),
57            V(1, 2),
58            V(2, 1),
59            V(2, 1.5),
60            V(2, 2),
61            V(3, 1),
62            V(3, 1.5),
63            V(3, 2),
64        };
65        typedef test_compare<std::less<int> > C;
66        typedef other_allocator<V> A;
67        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
68        std::multimap<int, double, C, A> m = mo;
69        assert(m == mo);
70        assert(m.get_allocator() == A(-2));
71        assert(m.key_comp() == C(5));
72
73        assert(mo.get_allocator() == A(7));
74        assert(mo.key_comp() == C(5));
75    }
76#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
77#if __cplusplus >= 201103L
78    {
79        typedef std::pair<const int, double> V;
80        V ar[] =
81        {
82            V(1, 1),
83            V(1, 1.5),
84            V(1, 2),
85            V(2, 1),
86            V(2, 1.5),
87            V(2, 2),
88            V(3, 1),
89            V(3, 1.5),
90            V(3, 2),
91        };
92        typedef test_compare<std::less<int> > C;
93        typedef min_allocator<V> A;
94        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
95        std::multimap<int, double, C, A> m = mo;
96        assert(m == mo);
97        assert(m.get_allocator() == A());
98        assert(m.key_comp() == C(5));
99
100        assert(mo.get_allocator() == A());
101        assert(mo.key_comp() == C(5));
102    }
103#endif
104}
105