1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03
10
11 // <map>
12
13 // class map
14
15 // map(initializer_list<value_type> il, const key_compare& comp);
16
17 #include <map>
18 #include <cassert>
19 #include "test_macros.h"
20 #include "../../../test_compare.h"
21 #include "min_allocator.h"
22
main(int,char **)23 int main(int, char**)
24 {
25 {
26 typedef std::pair<const int, double> V;
27 typedef test_less<int> C;
28 std::map<int, double, C> m({
29 {1, 1},
30 {1, 1.5},
31 {1, 2},
32 {2, 1},
33 {2, 1.5},
34 {2, 2},
35 {3, 1},
36 {3, 1.5},
37 {3, 2}
38 }, C(3));
39 assert(m.size() == 3);
40 assert(std::distance(m.begin(), m.end()) == 3);
41 assert(*m.begin() == V(1, 1));
42 assert(*std::next(m.begin()) == V(2, 1));
43 assert(*std::next(m.begin(), 2) == V(3, 1));
44 assert(m.key_comp() == C(3));
45 }
46 {
47 typedef std::pair<const int, double> V;
48 typedef test_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(std::distance(m.begin(), m.end()) == 3);
62 assert(*m.begin() == V(1, 1));
63 assert(*std::next(m.begin()) == V(2, 1));
64 assert(*std::next(m.begin(), 2) == V(3, 1));
65 assert(m.key_comp() == C(3));
66 }
67
68 return 0;
69 }
70