| 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 | // [[nodiscard]] bool empty() const noexcept; |
| 14 | |
| 15 | #include <flat_set> |
| 16 | #include <cassert> |
| 17 | #include <deque> |
| 18 | #include <functional> |
| 19 | #include <utility> |
| 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_multiset<Key, std::less<int>, KeyContainer>; |
| 30 | M m; |
| 31 | ASSERT_SAME_TYPE(decltype(m.empty()), bool); |
| 32 | ASSERT_NOEXCEPT(m.empty()); |
| 33 | assert(m.empty()); |
| 34 | assert(std::as_const(m).empty()); |
| 35 | m = {1}; |
| 36 | assert(!m.empty()); |
| 37 | m.clear(); |
| 38 | assert(m.empty()); |
| 39 | } |
| 40 | |
| 41 | void test() { |
| 42 | test_one<std::vector<int>>(); |
| 43 | test_one<std::deque<int>>(); |
| 44 | test_one<MinSequenceContainer<int>>(); |
| 45 | test_one<std::vector<int, min_allocator<int>>>(); |
| 46 | } |
| 47 | |
| 48 | int main(int, char**) { |
| 49 | test(); |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |