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 typedef std::pair<const int, int> KV;
25 {
26 typedef limited_allocator<KV, 10> A;
27 typedef std::multimap<int, int, std::less<int>, A> C;
28 C c;
29 assert(c.max_size() <= 10);
30 LIBCPP_ASSERT(c.max_size() == 10);
31 }
32 {
33 typedef limited_allocator<KV, (std::size_t)-1> A;
34 typedef std::multimap<int, int, std::less<int>, A> C;
35 const C::size_type max_dist = static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
36 C c;
37 assert(c.max_size() <= max_dist);
38 LIBCPP_ASSERT(c.max_size() == max_dist);
39 }
40 {
41 typedef std::multimap<char, int> C;
42 const C::size_type max_dist = static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
43 C c;
44 assert(c.max_size() <= max_dist);
45 assert(c.max_size() <= alloc_max_size(c.get_allocator()));
46 }
47
48 return 0;
49}
50

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