1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // size_type max_size() const;
18 #include <type_traits>
20 #include "test_allocator.h"
21 #include "test_macros.h"
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
;
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());
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());
47 assert(c
.max_size() <= max_dist
);
48 assert(c
.max_size() <= alloc_max_size(c
.get_allocator()));