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// <vector>
10// vector<bool>
11
12// vector(size_type n, const value_type& x);
13
14#include <vector>
15#include <cassert>
16
17#include "test_macros.h"
18#include "min_allocator.h"
19
20template <class C>
21TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, const typename C::value_type& x) {
22 C c(n, x);
23 LIBCPP_ASSERT(c.__invariants());
24 assert(c.size() == n);
25 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
26 assert(*i == x);
27}
28
29TEST_CONSTEXPR_CXX20 bool tests() {
30 test<std::vector<bool> >(50, true);
31#if TEST_STD_VER >= 11
32 test<std::vector<bool, min_allocator<bool>> >(50, true);
33#endif
34
35 return true;
36}
37
38int main(int, char**) {
39 tests();
40#if TEST_STD_VER > 17
41 static_assert(tests());
42#endif
43 return 0;
44}
45

source code of libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp