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 max_size() const;
14
15#include <cassert>
16#include <limits>
17#include <map>
18#include <type_traits>
19
20#include "test_allocator.h"
21#include "test_macros.h"
22
23int main(int, char**)
24{
25 typedef std::pair<const int, int> KV;
26 {
27 typedef limited_allocator<KV, 10> A;
28 typedef std::multimap<int, int, std::less<int>, A> C;
29 C c;
30 assert(c.max_size() <= 10);
31 LIBCPP_ASSERT(c.max_size() == 10);
32 }
33 {
34 typedef limited_allocator<KV, (std::size_t)-1> A;
35 typedef std::multimap<int, int, std::less<int>, A> C;
36 const C::size_type max_dist =
37 static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
38 C c;
39 assert(c.max_size() <= max_dist);
40 LIBCPP_ASSERT(c.max_size() == max_dist);
41 }
42 {
43 typedef std::multimap<char, int> C;
44 const C::size_type max_dist =
45 static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
46 C c;
47 assert(c.max_size() <= max_dist);
48 assert(c.max_size() <= alloc_max_size(c.get_allocator()));
49 }
50
51 return 0;
52}
53

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