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 //===----------------------------------------------------------------------===//
12 // void reserve(size_type n);
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 #include "test_allocator.h"
22 TEST_CONSTEXPR_CXX20
bool tests()
27 assert(v
.capacity() >= 10);
30 std::vector
<bool> v(100);
31 assert(v
.capacity() >= 100);
33 assert(v
.size() == 100);
34 assert(v
.capacity() >= 100);
36 assert(v
.size() == 100);
37 assert(v
.capacity() >= 150);
39 #if TEST_STD_VER >= 11
41 std::vector
<bool, min_allocator
<bool>> v
;
43 assert(v
.capacity() >= 10);
46 std::vector
<bool, explicit_allocator
<bool>> v
;
48 assert(v
.capacity() >= 10);
51 std::vector
<bool, min_allocator
<bool>> v(100);
52 assert(v
.capacity() >= 100);
54 assert(v
.size() == 100);
55 assert(v
.capacity() >= 100);
57 assert(v
.size() == 100);
58 assert(v
.capacity() >= 150);
61 #ifndef TEST_HAS_NO_EXCEPTIONS
62 if (!TEST_IS_CONSTANT_EVALUATED
) {
63 std::vector
<bool, limited_allocator
<bool, 10> > v
;
66 // A typical implementation would allocate chunks of bits.
67 // In libc++ the chunk has the same size as the machine word. It is
68 // reasonable to assume that in practice no implementation would use
69 // 64 kB or larger chunks.
70 v
.reserve(10 * 65536);
72 } catch (const std::length_error
&) {
75 assert(v
.capacity() >= 5);
86 static_assert(tests());