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);
16
17#include <map>
18#include <cassert>
19
20#include "test_macros.h"
21#include "min_allocator.h"
22
23int main(int, char**) {
24 {
25 typedef std::pair<const int, double> V;
26 std::map<int, double> m = {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}};
27 assert(m.size() == 3);
28 assert(std::distance(m.begin(), m.end()) == 3);
29 assert(*m.begin() == V(1, 1));
30 assert(*std::next(m.begin()) == V(2, 1));
31 assert(*std::next(m.begin(), 2) == V(3, 1));
32 }
33 {
34 typedef std::pair<const int, double> V;
35 std::map<int, double, std::less<int>, min_allocator<V>> m = {
36 {1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}};
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
44 return 0;
45}
46

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