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_multimap
12
13// size_type size() const noexcept;
14
15#include <unordered_map>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21int main(int, char**) {
22 {
23 typedef std::unordered_multimap<int, double> M;
24 M m;
25 ASSERT_NOEXCEPT(m.size());
26 assert(m.size() == 0);
27 m.insert(x: M::value_type(2, 1.5));
28 assert(m.size() == 1);
29 m.insert(x: M::value_type(1, 1.5));
30 assert(m.size() == 2);
31 m.insert(x: M::value_type(3, 1.5));
32 assert(m.size() == 3);
33 m.erase(position: m.begin());
34 assert(m.size() == 2);
35 m.erase(position: m.begin());
36 assert(m.size() == 1);
37 m.erase(position: m.begin());
38 assert(m.size() == 0);
39 }
40#if TEST_STD_VER >= 11
41 {
42 typedef std::
43 unordered_multimap<int, double, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, double>>>
44 M;
45 M m;
46 ASSERT_NOEXCEPT(m.size());
47 assert(m.size() == 0);
48 m.insert(M::value_type(2, 1.5));
49 assert(m.size() == 1);
50 m.insert(M::value_type(1, 1.5));
51 assert(m.size() == 2);
52 m.insert(M::value_type(3, 1.5));
53 assert(m.size() == 3);
54 m.erase(m.begin());
55 assert(m.size() == 2);
56 m.erase(m.begin());
57 assert(m.size() == 1);
58 m.erase(m.begin());
59 assert(m.size() == 0);
60 }
61#endif
62
63 return 0;
64}
65

source code of libcxx/test/std/containers/unord/unord.multimap/size.pass.cpp