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, c++11 |
10 | // <vector> |
11 | // vector<bool> |
12 | |
13 | // template <class... Args> iterator emplace(const_iterator pos, Args&&... args); |
14 | |
15 | #include <vector> |
16 | #include <cassert> |
17 | #include "test_macros.h" |
18 | #include "min_allocator.h" |
19 | |
20 | TEST_CONSTEXPR_CXX20 bool tests() |
21 | { |
22 | { |
23 | typedef std::vector<bool> C; |
24 | C c; |
25 | |
26 | C::iterator i = c.emplace(pos: c.cbegin()); |
27 | assert(i == c.begin()); |
28 | assert(c.size() == 1); |
29 | assert(c.front() == false); |
30 | |
31 | i = c.emplace(pos: c.cend(), args: true); |
32 | assert(i == c.end()-1); |
33 | assert(c.size() == 2); |
34 | assert(c.front() == false); |
35 | assert(c.back() == true); |
36 | |
37 | i = c.emplace(pos: c.cbegin()+1, args: true); |
38 | assert(i == c.begin()+1); |
39 | assert(c.size() == 3); |
40 | assert(c.front() == false); |
41 | assert(c[1] == true); |
42 | assert(c.back() == true); |
43 | } |
44 | { |
45 | typedef std::vector<bool, min_allocator<bool>> C; |
46 | C c; |
47 | |
48 | C::iterator i = c.emplace(c.cbegin()); |
49 | assert(i == c.begin()); |
50 | assert(c.size() == 1); |
51 | assert(c.front() == false); |
52 | |
53 | i = c.emplace(c.cend(), true); |
54 | assert(i == c.end()-1); |
55 | assert(c.size() == 2); |
56 | assert(c.front() == false); |
57 | assert(c.back() == true); |
58 | |
59 | i = c.emplace(c.cbegin()+1, true); |
60 | assert(i == c.begin()+1); |
61 | assert(c.size() == 3); |
62 | assert(c.size() == 3); |
63 | assert(c.front() == false); |
64 | assert(c[1] == true); |
65 | assert(c.back() == true); |
66 | } |
67 | |
68 | return true; |
69 | } |
70 | |
71 | int main(int, char**) |
72 | { |
73 | tests(); |
74 | #if TEST_STD_VER > 17 |
75 | static_assert(tests()); |
76 | #endif |
77 | return 0; |
78 | } |
79 | |