1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 // template <class InputIterator>
15 // map(InputIterator first, InputIterator last,
16 // const key_compare& comp, const allocator_type& a);
21 #include "test_macros.h"
22 #include "../../../test_compare.h"
23 #include "test_allocator.h"
24 #include "min_allocator.h"
29 typedef std::pair<const int, double> V;
42 typedef test_compare<std::less<int> > C;
43 typedef test_allocator<V> A;
44 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
45 assert(m.get_allocator() == A(7));
46 assert(m.key_comp() == C(5));
47 assert(m.size() == 3);
48 assert(distance(m.begin(), m.end()) == 3);
49 assert(*m.begin() == V(1, 1));
50 assert(*next(m.begin()) == V(2, 1));
51 assert(*next(m.begin(), 2) == V(3, 1));
53 #if TEST_STD_VER >= 11
55 typedef std::pair<const int, double> V;
68 typedef test_compare<std::less<int> > C;
69 typedef min_allocator<V> A;
70 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
71 assert(m.get_allocator() == A());
72 assert(m.key_comp() == C(5));
73 assert(m.size() == 3);
74 assert(distance(m.begin(), m.end()) == 3);
75 assert(*m.begin() == V(1, 1));
76 assert(*next(m.begin()) == V(2, 1));
77 assert(*next(m.begin(), 2) == V(3, 1));
81 typedef std::pair<const int, double> V;
95 typedef std::pair<const int, double> V;
96 typedef min_allocator<V> A;
97 typedef test_compare<std::less<int> > C;
99 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
101 assert(m.size() == 3);
102 assert(distance(m.begin(), m.end()) == 3);
103 assert(*m.begin() == V(1, 1));
104 assert(*next(m.begin()) == V(2, 1));
105 assert(*next(m.begin(), 2) == V(3, 1));
106 assert(m.get_allocator() == a);
109 typedef std::pair<const int, double> V;
110 typedef explicit_allocator<V> A;
111 typedef test_compare<std::less<int> > C;
113 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
115 assert(m.size() == 3);
116 assert(distance(m.begin(), m.end()) == 3);
117 assert(*m.begin() == V(1, 1));
118 assert(*next(m.begin()) == V(2, 1));
119 assert(*next(m.begin(), 2) == V(3, 1));
120 assert(m.get_allocator() == a);