| 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 | // class flat_multimap |
| 14 | |
| 15 | // [[nodiscard]] bool empty() const noexcept; |
| 16 | |
| 17 | #include <flat_map> |
| 18 | #include <cassert> |
| 19 | #include <deque> |
| 20 | #include <functional> |
| 21 | #include <utility> |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "MinSequenceContainer.h" |
| 25 | #include "test_macros.h" |
| 26 | #include "min_allocator.h" |
| 27 | |
| 28 | template <class KeyContainer, class ValueContainer> |
| 29 | void 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<int>, KeyContainer, ValueContainer>; |
| 33 | M m; |
| 34 | ASSERT_SAME_TYPE(decltype(m.empty()), bool); |
| 35 | ASSERT_NOEXCEPT(m.empty()); |
| 36 | assert(m.empty()); |
| 37 | assert(std::as_const(m).empty()); |
| 38 | m = {{1, 1.0}, {1, 2.0}}; |
| 39 | assert(!m.empty()); |
| 40 | m.clear(); |
| 41 | assert(m.empty()); |
| 42 | } |
| 43 | |
| 44 | int main(int, char**) { |
| 45 | test<std::vector<int>, std::vector<double>>(); |
| 46 | test<std::deque<int>, std::vector<double>>(); |
| 47 | test<MinSequenceContainer<int>, MinSequenceContainer<double>>(); |
| 48 | test<std::vector<int, min_allocator<int>>, std::vector<double, min_allocator<double>>>(); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |