| 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 | // void insert(initializer_list<value_type> il); |
| 16 | |
| 17 | #include <map> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | #include "min_allocator.h" |
| 22 | |
| 23 | int 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}, {3, 1}, {3, 1.5}, {3, 2}}; |
| 27 | m.insert(list: { |
| 28 | {2, 1}, |
| 29 | {2, 1.5}, |
| 30 | {2, 2}, |
| 31 | }); |
| 32 | assert(m.size() == 3); |
| 33 | assert(std::distance(m.begin(), m.end()) == 3); |
| 34 | assert(*m.begin() == V(1, 1)); |
| 35 | assert(*std::next(m.begin()) == V(2, 1)); |
| 36 | assert(*std::next(m.begin(), 2) == V(3, 1)); |
| 37 | } |
| 38 | { |
| 39 | typedef std::pair<const int, double> V; |
| 40 | std::map<int, double, std::less<int>, min_allocator<V>> m = {{1, 1}, {1, 1.5}, {1, 2}, {3, 1}, {3, 1.5}, {3, 2}}; |
| 41 | m.insert({ |
| 42 | {2, 1}, |
| 43 | {2, 1.5}, |
| 44 | {2, 2}, |
| 45 | }); |
| 46 | assert(m.size() == 3); |
| 47 | assert(std::distance(m.begin(), m.end()) == 3); |
| 48 | assert(*m.begin() == V(1, 1)); |
| 49 | assert(*std::next(m.begin()) == V(2, 1)); |
| 50 | assert(*std::next(m.begin(), 2) == V(3, 1)); |
| 51 | } |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |