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 // template <class Iter>
13 // iterator insert(const_iterator position, Iter first, Iter last);
19 #include "test_macros.h"
20 #include "test_iterators.h"
21 #include "min_allocator.h"
26 std::vector
<bool> v(100);
27 bool a
[] = {1, 0, 0, 1, 1};
28 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
29 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, input_iterator
<const bool*>(a
),
30 input_iterator
<const bool*>(a
+N
));
31 assert(v
.size() == 100 + N
);
32 assert(i
== v
.begin() + 10);
34 for (j
= 0; j
< 10; ++j
)
36 for (std::size_t k
= 0; k
< N
; ++j
, ++k
)
38 for (; j
< v
.size(); ++j
)
42 std::vector
<bool> v(100);
43 bool a
[] = {1, 0, 0, 1, 1};
44 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
45 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, forward_iterator
<const bool*>(a
),
46 forward_iterator
<const bool*>(a
+N
));
47 assert(v
.size() == 100 + N
);
48 assert(i
== v
.begin() + 10);
50 for (j
= 0; j
< 10; ++j
)
52 for (std::size_t k
= 0; k
< N
; ++j
, ++k
)
58 std::vector
<bool> v(100);
59 while(v
.size() < v
.capacity()) v
.push_back(false);
61 bool a
[] = {1, 0, 0, 1, 1};
62 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
63 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, forward_iterator
<const bool*>(a
),
64 forward_iterator
<const bool*>(a
+N
));
65 assert(v
.size() == sz
+ N
);
66 assert(i
== v
.begin() + 10);
68 for (j
= 0; j
< 10; ++j
)
70 for (std::size_t k
= 0; k
< N
; ++j
, ++k
)
72 for (; j
< v
.size(); ++j
)
76 std::vector
<bool> v(100);
77 while(v
.size() < v
.capacity()) v
.push_back(false);
78 v
.pop_back(); v
.pop_back(); v
.pop_back();
80 bool a
[] = {1, 0, 0, 1, 1};
81 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
82 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, forward_iterator
<const bool*>(a
),
83 forward_iterator
<const bool*>(a
+N
));
84 assert(v
.size() == sz
+ N
);
85 assert(i
== v
.begin() + 10);
87 for (j
= 0; j
< 10; ++j
)
89 for (std::size_t k
= 0; k
< N
; ++j
, ++k
)
91 for (; j
< v
.size(); ++j
)
94 #if TEST_STD_VER >= 11
96 std::vector
<bool, min_allocator
<bool>> v(100);
97 bool a
[] = {1, 0, 0, 1, 1};
98 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
99 std::vector
<bool, min_allocator
<bool>>::iterator i
= v
.insert(v
.cbegin() + 10, input_iterator
<const bool*>(a
),
100 input_iterator
<const bool*>(a
+N
));
101 assert(v
.size() == 100 + N
);
102 assert(i
== v
.begin() + 10);
104 for (j
= 0; j
< 10; ++j
)
106 for (std::size_t k
= 0; k
< N
; ++j
, ++k
)
107 assert(v
[j
] == a
[k
]);
108 for (; j
< v
.size(); ++j
)
112 std::vector
<bool, min_allocator
<bool>> v(100);
113 bool a
[] = {1, 0, 0, 1, 1};
114 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
115 std::vector
<bool, min_allocator
<bool>>::iterator i
= v
.insert(v
.cbegin() + 10, forward_iterator
<const bool*>(a
),
116 forward_iterator
<const bool*>(a
+N
));
117 assert(v
.size() == 100 + N
);
118 assert(i
== v
.begin() + 10);
120 for (j
= 0; j
< 10; ++j
)
122 for (std::size_t k
= 0; k
< N
; ++j
, ++k
)
123 assert(v
[j
] == a
[k
]);
124 for (; j
< v
.size(); ++j
)