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