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