Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / associative / map / map.access / max_size.pass.cpp
blobe10f20359bb18e8d21c9d36c2377005539f3e8df
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 //===----------------------------------------------------------------------===//
9 // <map>
11 // class map
13 // size_type max_size() const;
15 #include <cassert>
16 #include <limits>
17 #include <map>
18 #include <type_traits>
20 #include "test_allocator.h"
21 #include "test_macros.h"
23 int main(int, char**)
25 typedef std::pair<const int, int> KV;
27 typedef limited_allocator<KV, 10> A;
28 typedef std::map<int, int, std::less<int>, A> C;
29 C c;
30 assert(c.max_size() <= 10);
31 LIBCPP_ASSERT(c.max_size() == 10);
34 typedef limited_allocator<KV, (std::size_t)-1> A;
35 typedef std::map<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);
43 typedef std::map<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()));
51 return 0;