1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <map>
11
12 // class multimap
13
14 // size_type max_size() const;
15
16 #include <cassert>
17 #include <limits>
18 #include <map>
19 #include <type_traits>
20
21 #include "test_allocator.h"
22 #include "test_macros.h"
23
main()24 int main()
25 {
26 typedef std::pair<const int, int> KV;
27 {
28 typedef limited_allocator<KV, 10> A;
29 typedef std::multimap<int, int, std::less<int>, A> C;
30 C c;
31 assert(c.max_size() <= 10);
32 LIBCPP_ASSERT(c.max_size() == 10);
33 }
34 {
35 typedef limited_allocator<KV, (size_t)-1> A;
36 typedef std::multimap<int, int, std::less<int>, A> C;
37 const C::size_type max_dist =
38 static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
39 C c;
40 assert(c.max_size() <= max_dist);
41 LIBCPP_ASSERT(c.max_size() == max_dist);
42 }
43 {
44 typedef std::multimap<char, int> C;
45 const C::size_type max_dist =
46 static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
47 C c;
48 assert(c.max_size() <= max_dist);
49 assert(c.max_size() <= alloc_max_size(c.get_allocator()));
50 }
51 }
52