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 map
13
14 // map(initializer_list<value_type> il, const key_compare& comp);
15
16 #include <map>
17 #include <cassert>
18 #include "../../../test_compare.h"
19 #include "min_allocator.h"
20
main()21 int main()
22 {
23 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
24 {
25 typedef std::pair<const int, double> V;
26 typedef test_compare<std::less<int> > C;
27 std::map<int, double, C> m({
28 {1, 1},
29 {1, 1.5},
30 {1, 2},
31 {2, 1},
32 {2, 1.5},
33 {2, 2},
34 {3, 1},
35 {3, 1.5},
36 {3, 2}
37 }, C(3));
38 assert(m.size() == 3);
39 assert(distance(m.begin(), m.end()) == 3);
40 assert(*m.begin() == V(1, 1));
41 assert(*next(m.begin()) == V(2, 1));
42 assert(*next(m.begin(), 2) == V(3, 1));
43 assert(m.key_comp() == C(3));
44 }
45 #if __cplusplus >= 201103L
46 {
47 typedef std::pair<const int, double> V;
48 typedef test_compare<std::less<int> > C;
49 std::map<int, double, C, min_allocator<std::pair<const int, double>>> m({
50 {1, 1},
51 {1, 1.5},
52 {1, 2},
53 {2, 1},
54 {2, 1.5},
55 {2, 2},
56 {3, 1},
57 {3, 1.5},
58 {3, 2}
59 }, C(3));
60 assert(m.size() == 3);
61 assert(distance(m.begin(), m.end()) == 3);
62 assert(*m.begin() == V(1, 1));
63 assert(*next(m.begin()) == V(2, 1));
64 assert(*next(m.begin(), 2) == V(3, 1));
65 assert(m.key_comp() == C(3));
66 }
67 #endif
68 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
69 }
70