| 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_set& 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 <vector> |
| 21 | |
| 22 | #include "MinSequenceContainer.h" |
| 23 | #include "test_macros.h" |
| 24 | #include "min_allocator.h" |
| 25 | |
| 26 | template <class KeyContainer> |
| 27 | void test_one() { |
| 28 | using Key = typename KeyContainer::value_type; |
| 29 | using M = std::flat_set<Key, std::less<Key>, KeyContainer>; |
| 30 | { |
| 31 | M m = {8, 10}; |
| 32 | assert(m.size() == 2); |
| 33 | std::same_as<M&> decltype(auto) r = m = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5}; |
| 34 | assert(&r == &m); |
| 35 | int expected[] = {1, 2, 3, 4, 5, 6}; |
| 36 | assert(std::ranges::equal(m, expected)); |
| 37 | } |
| 38 | { |
| 39 | M m = {10, 8}; |
| 40 | assert(m.size() == 2); |
| 41 | std::same_as<M&> decltype(auto) r = m = {3}; |
| 42 | assert(&r == &m); |
| 43 | int expected[] = {3}; |
| 44 | assert(std::ranges::equal(m, expected)); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void test() { |
| 49 | test_one<std::vector<int>>(); |
| 50 | test_one<std::vector<int>>(); |
| 51 | test_one<std::deque<int>>(); |
| 52 | test_one<MinSequenceContainer<int>>(); |
| 53 | test_one<std::vector<int, min_allocator<int>>>(); |
| 54 | test_one<std::vector<int, min_allocator<int>>>(); |
| 55 | } |
| 56 | |
| 57 | int main(int, char**) { |
| 58 | test(); |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |