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 //===----------------------------------------------------------------------===//
13 // template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 #include "asan_testing.h"
22 TEST_CONSTEXPR_CXX20
bool tests() {
26 assert(is_contiguous_container_asan_correct(v
));
28 v
.emplace(v
.begin(), v
.back());
30 assert(is_contiguous_container_asan_correct(v
));
35 assert(is_contiguous_container_asan_correct(v
));
37 v
.emplace(v
.begin(), v
.back());
39 assert(is_contiguous_container_asan_correct(v
));
42 std::vector
<int, min_allocator
<int>> v
;
44 assert(is_contiguous_container_asan_correct(v
));
46 v
.emplace(v
.begin(), v
.back());
48 assert(is_contiguous_container_asan_correct(v
));
51 std::vector
<int, min_allocator
<int>> v
;
53 assert(is_contiguous_container_asan_correct(v
));
55 v
.emplace(v
.begin(), v
.back());
57 assert(is_contiguous_container_asan_correct(v
));
60 std::vector
<int, safe_allocator
<int>> v
;
62 assert(is_contiguous_container_asan_correct(v
));
64 v
.emplace(v
.begin(), v
.back());
66 assert(is_contiguous_container_asan_correct(v
));
69 std::vector
<int, safe_allocator
<int>> v
;
71 assert(is_contiguous_container_asan_correct(v
));
73 v
.emplace(v
.begin(), v
.back());
75 assert(is_contiguous_container_asan_correct(v
));
80 std::size_t old_capacity
= v
.capacity();
81 assert(old_capacity
>= 8);
83 v
.resize(4); // keep the existing capacity
84 assert(v
.capacity() == old_capacity
);
86 v
.emplace(v
.cend(), 42);
87 assert(v
.size() == 5);
88 assert(v
.capacity() == old_capacity
);
95 int main(int, char**) {
98 static_assert(tests());