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, c++11, c++14, c++17, c++20
10
11// <flat_map>
12
13// flat_multimap& operator=(initializer_list<value_type> il);
14
15#include <algorithm>
16#include <cassert>
17#include <deque>
18#include <flat_map>
19#include <functional>
20#include <ranges>
21#include <vector>
22
23#include "MinSequenceContainer.h"
24#include "test_macros.h"
25#include "min_allocator.h"
26#include "test_allocator.h"
27
28template <class KeyContainer, class ValueContainer>
29void test() {
30 using Key = typename KeyContainer::value_type;
31 using Value = typename ValueContainer::value_type;
32 using M = std::flat_multimap<Key, Value, std::less<Key>, KeyContainer, ValueContainer>;
33 {
34 M m = {{8, 8}, {10, 10}};
35 assert(m.size() == 2);
36 m = {{3, 0}, {1, 0}, {2, 0}, {2, 1}, {3, 1}, {4, 0}, {3, 2}, {5, 0}, {6, 0}, {5, 1}};
37 std::pair<int, int> expected[] = {{1, 0}, {2, 0}, {2, 1}, {3, 0}, {3, 1}, {3, 2}, {4, 0}, {5, 0}, {5, 1}, {6, 0}};
38 assert(std::ranges::equal(m, expected));
39 }
40 {
41 M m = {{10, 1}, {8, 1}};
42 assert(m.size() == 2);
43 m = {{3, 2}};
44 std::pair<double, double> expected[] = {{3, 2}};
45 assert(std::ranges::equal(m, expected));
46 }
47}
48
49int main(int, char**) {
50 test<std::vector<int>, std::vector<int>>();
51 test<std::vector<int>, std::vector<double>>();
52 test<std::deque<int>, std::vector<double>>();
53 test<MinSequenceContainer<int>, MinSequenceContainer<double>>();
54 test<std::vector<int, min_allocator<int>>, std::vector<double, min_allocator<double>>>();
55 test<std::vector<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>();
56
57 return 0;
58}
59

source code of libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/assign_initializer_list.pass.cpp