[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / emplace_back.pass.cpp
blobfccf6e5fb962ca2cf80244fe0fa4b89aafe6cc02
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
10 // <vector>
11 // vector.bool
13 // template <class... Args> reference emplace_back(Args&&... args);
14 // return type is 'reference' in C++17; 'void' before
16 #include <vector>
17 #include <cassert>
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20 bool tests()
24 typedef std::vector<bool> C;
25 C c;
26 #if TEST_STD_VER > 14
27 typedef C::reference Ref;
28 Ref r1 = c.emplace_back();
29 assert(c.size() == 1);
30 assert(c.front() == false);
31 r1 = true;
32 assert(c.front() == true);
33 r1 = false;
34 Ref r2 = c.emplace_back(true);
35 assert(c.size() == 2);
36 assert(c.front() == false);
37 assert(c.back() == true);
38 r2 = false;
39 assert(c.back() == false);
40 r2 = true;
41 #else
42 c.emplace_back();
43 assert(c.size() == 1);
44 assert(c.front() == false);
45 c.emplace_back(true);
46 assert(c.size() == 2);
47 assert(c.front() == false);
48 assert(c.back() == true);
49 #endif
50 c.emplace_back(true);
51 assert(c.size() == 3);
52 assert(c.front() == false);
53 assert(c[1] == true);
54 assert(c.back() == true);
57 typedef std::vector<bool, min_allocator<bool>> C;
58 C c;
60 #if TEST_STD_VER > 14
61 typedef C::reference Ref;
62 Ref r1 = c.emplace_back();
63 assert(c.size() == 1);
64 assert(c.front() == false);
65 r1 = true;
66 assert(c.front() == true);
67 r1 = false;
68 Ref r2 = c.emplace_back(true);
69 assert(c.size() == 2);
70 assert(c.front() == false);
71 assert(c.back() == true);
72 r2 = false;
73 assert(c.back() == false);
74 r2 = true;
75 #else
76 c.emplace_back();
77 assert(c.size() == 1);
78 assert(c.front() == false);
79 c.emplace_back(true);
80 assert(c.size() == 2);
81 assert(c.front() == false);
82 assert(c.back() == true);
83 #endif
84 c.emplace_back(true);
85 assert(c.size() == 3);
86 assert(c.front() == false);
87 assert(c[1] == true);
88 assert(c.back() == true);
91 return true;
94 int main(int, char**)
96 tests();
97 #if TEST_STD_VER > 17
98 static_assert(tests());
99 #endif
100 return 0;