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

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