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_set>
12
13// flat_multiset& operator=(initializer_list<value_type> il);
14
15#include <algorithm>
16#include <cassert>
17#include <deque>
18#include <flat_set>
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>
29void test() {
30 using Key = typename KeyContainer::value_type;
31 using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
32 {
33 M m = {8, 10};
34 assert(m.size() == 2);
35 m = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5};
36 int expected[] = {1, 2, 2, 3, 3, 3, 4, 5, 5, 6};
37 assert(std::ranges::equal(m, expected));
38 }
39 {
40 M m = {10, 8};
41 assert(m.size() == 2);
42 m = {3};
43 double expected[] = {3};
44 assert(std::ranges::equal(m, expected));
45 }
46 {
47 // was empty
48 M m;
49 assert(m.size() == 0);
50 m = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5};
51 int expected[] = {1, 2, 2, 3, 3, 3, 4, 5, 5, 6};
52 assert(std::ranges::equal(m, expected));
53 }
54}
55
56void test() {
57 test<std::vector<int>>();
58 test<std::vector<double>>();
59 test<std::deque<int>>();
60 test<MinSequenceContainer<int>>();
61 test<std::vector<int, min_allocator<int>>>();
62}
63
64int main(int, char**) {
65 test();
66
67 return 0;
68}
69

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