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// <map>
10
11// class map
12
13// template <class InputIterator>
14// map(InputIterator first, InputIterator last);
15
16#include <map>
17#include <cassert>
18
19#include "test_macros.h"
20#include "min_allocator.h"
21
22int main(int, char**) {
23 {
24 typedef std::pair<const int, double> V;
25 V ar[] = {
26 V(1, 1),
27 V(1, 1.5),
28 V(1, 2),
29 V(2, 1),
30 V(2, 1.5),
31 V(2, 2),
32 V(3, 1),
33 V(3, 1.5),
34 V(3, 2),
35 };
36 std::map<int, double> m(ar, ar + sizeof(ar) / sizeof(ar[0]));
37 assert(m.size() == 3);
38 assert(std::distance(m.begin(), m.end()) == 3);
39 assert(*m.begin() == V(1, 1));
40 assert(*std::next(m.begin()) == V(2, 1));
41 assert(*std::next(m.begin(), 2) == V(3, 1));
42 }
43#if TEST_STD_VER >= 11
44 {
45 typedef std::pair<const int, double> V;
46 V ar[] = {
47 V(1, 1),
48 V(1, 1.5),
49 V(1, 2),
50 V(2, 1),
51 V(2, 1.5),
52 V(2, 2),
53 V(3, 1),
54 V(3, 1.5),
55 V(3, 2),
56 };
57 std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(
58 ar, ar + sizeof(ar) / sizeof(ar[0]));
59 assert(m.size() == 3);
60 assert(std::distance(m.begin(), m.end()) == 3);
61 assert(*m.begin() == V(1, 1));
62 assert(*std::next(m.begin()) == V(2, 1));
63 assert(*std::next(m.begin(), 2) == V(3, 1));
64 }
65#endif
66
67 return 0;
68}
69

source code of libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp