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// UNSUPPORTED: c++03
10
11// <vector>
12
13// iterator insert(const_iterator p, initializer_list<value_type> il);
14
15#include <vector>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21TEST_CONSTEXPR_CXX20 bool tests()
22{
23 {
24 std::vector<bool> d(10, true);
25 std::vector<bool>::iterator i = d.insert(p: d.cbegin() + 2, l: {false, true, true, false});
26 assert(d.size() == 14);
27 assert(i == d.begin() + 2);
28 assert(d[0] == true);
29 assert(d[1] == true);
30 assert(d[2] == false);
31 assert(d[3] == true);
32 assert(d[4] == true);
33 assert(d[5] == false);
34 assert(d[6] == true);
35 assert(d[7] == true);
36 assert(d[8] == true);
37 assert(d[9] == true);
38 assert(d[10] == true);
39 assert(d[11] == true);
40 assert(d[12] == true);
41 assert(d[13] == true);
42 }
43 {
44 std::vector<bool, min_allocator<bool>> d(10, true);
45 std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
46 assert(d.size() == 14);
47 assert(i == d.begin() + 2);
48 assert(d[0] == true);
49 assert(d[1] == true);
50 assert(d[2] == false);
51 assert(d[3] == true);
52 assert(d[4] == true);
53 assert(d[5] == false);
54 assert(d[6] == true);
55 assert(d[7] == true);
56 assert(d[8] == true);
57 assert(d[9] == true);
58 assert(d[10] == true);
59 assert(d[11] == true);
60 assert(d[12] == true);
61 assert(d[13] == true);
62 }
63
64 return true;
65}
66
67int main(int, char**)
68{
69 tests();
70#if TEST_STD_VER > 17
71 static_assert(tests());
72#endif
73 return 0;
74}
75

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