Debian Codegraph @

libcxx/test/std/containers/unord/unord.map/empty.pass.cpp

raw
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 // <unordered_map>
10
11 // class unordered_map
12
13 // bool empty() const noexcept;
14
15 #include <unordered_map>
16 #include <cassert>
17
18 #include "test_macros.h"
19 #include "min_allocator.h"
20
21 int main(int, char**) {
22 {
23 typedef std::unordered_map<int, double> M;
24 M m;
25 ASSERT_NOEXCEPT(m.empty());
26 assert(m.empty());
27 m.insert(M::value_type(1, 1.5));
28 assert(!m.empty());
29 m.clear();
30 assert(m.empty());
31 }
32 #if TEST_STD_VER >= 11
33 {
34 typedef std::
35 unordered_map<int, double, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, double>>>
36 M;
37 M m;
38 ASSERT_NOEXCEPT(m.empty());
39 assert(m.empty());
40 m.insert(M::value_type(1, 1.5));
41 assert(!m.empty());
42 m.clear();
43 assert(m.empty());
44 }
45 #endif
46
47 return 0;
48 }