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 // iterator insert(const_iterator position, const value_type& x);
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20
bool tests()
24 std::vector
<bool> v(100);
25 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, 1);
26 assert(v
.size() == 101);
27 assert(i
== v
.begin() + 10);
29 for (j
= 0; j
< 10; ++j
)
32 for (++j
; j
< v
.size(); ++j
)
36 std::vector
<bool> v(100);
37 while(v
.size() < v
.capacity()) v
.push_back(false);
38 std::size_t sz
= v
.size();
39 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, 1);
40 assert(v
.size() == sz
+ 1);
41 assert(i
== v
.begin() + 10);
43 for (j
= 0; j
< 10; ++j
)
46 for (++j
; j
< v
.size(); ++j
)
50 std::vector
<bool> v(100);
51 while(v
.size() < v
.capacity()) v
.push_back(false);
52 v
.pop_back(); v
.pop_back();
53 std::size_t sz
= v
.size();
54 std::vector
<bool>::iterator i
= v
.insert(v
.cbegin() + 10, 1);
55 assert(v
.size() == sz
+ 1);
56 assert(i
== v
.begin() + 10);
58 for (j
= 0; j
< 10; ++j
)
61 for (++j
; j
< v
.size(); ++j
)
64 #if TEST_STD_VER >= 11
66 std::vector
<bool, explicit_allocator
<bool>> v(10);
67 std::vector
<bool, explicit_allocator
<bool>>::iterator i
68 = v
.insert(v
.cbegin() + 10, 1);
69 assert(v
.size() == 11);
70 assert(i
== v
.begin() + 10);
74 std::vector
<bool, min_allocator
<bool>> v(100);
75 std::vector
<bool, min_allocator
<bool>>::iterator i
= v
.insert(v
.cbegin() + 10, 1);
76 assert(v
.size() == 101);
77 assert(i
== v
.begin() + 10);
79 for (j
= 0; j
< 10; ++j
)
82 for (++j
; j
< v
.size(); ++j
)
94 static_assert(tests());