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// [[nodiscard]] bool empty() const noexcept;
14
15#include <flat_map>
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
26template <class KeyContainer, class ValueContainer>
27void test() {
28 using Key = typename KeyContainer::value_type;
29 using Value = typename ValueContainer::value_type;
30 using M = std::flat_multimap<Key, Value, std::less<int>, KeyContainer, ValueContainer>;
31 M m;
32 ASSERT_SAME_TYPE(decltype(m.empty()), bool);
33 ASSERT_NOEXCEPT(m.empty());
34 assert(m.empty());
35 assert(std::as_const(m).empty());
36 m = {{1, 1.0}};
37 assert(!m.empty());
38 m.clear();
39 assert(m.empty());
40}
41
42int main(int, char**) {
43 test<std::vector<int>, std::vector<double>>();
44 test<std::deque<int>, std::vector<double>>();
45 test<MinSequenceContainer<int>, MinSequenceContainer<double>>();
46 test<std::vector<int, min_allocator<int>>, std::vector<double, min_allocator<double>>>();
47
48 return 0;
49}
50

source code of libcxx/test/std/containers/container.adaptors/flat.map/flat.map.capacity/empty.pass.cpp