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 {
24 typedef std::unordered_multimap<int, double> M;
25 M m;
26 ASSERT_NOEXCEPT(m.size());
27 assert(m.size() == 0);
28 m.insert(x: M::value_type(2, 1.5));
29 assert(m.size() == 1);
30 m.insert(x: M::value_type(1, 1.5));
31 assert(m.size() == 2);
32 m.insert(x: M::value_type(3, 1.5));
33 assert(m.size() == 3);
34 m.erase(position: m.begin());
35 assert(m.size() == 2);
36 m.erase(position: m.begin());
37 assert(m.size() == 1);
38 m.erase(position: m.begin());
39 assert(m.size() == 0);
40 }
41#if TEST_STD_VER >= 11
42 {
43 typedef std::unordered_multimap<int, double, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, double>>> M;
44 M m;
45 ASSERT_NOEXCEPT(m.size());
46 assert(m.size() == 0);
47 m.insert(M::value_type(2, 1.5));
48 assert(m.size() == 1);
49 m.insert(M::value_type(1, 1.5));
50 assert(m.size() == 2);
51 m.insert(M::value_type(3, 1.5));
52 assert(m.size() == 3);
53 m.erase(m.begin());
54 assert(m.size() == 2);
55 m.erase(m.begin());
56 assert(m.size() == 1);
57 m.erase(m.begin());
58 assert(m.size() == 0);
59 }
60#endif
61
62 return 0;
63}
64

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