Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / set / set.special / member_swap.pass.cpp
blobee91ca3bcc34efa65f283a91eb1c3434b099d838
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 // <set>
11 // class set
13 // void swap(set& m);
15 #include <set>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 int main(int, char**)
24 typedef int V;
25 typedef std::set<int> M;
27 M m1;
28 M m2;
29 M m1_save = m1;
30 M m2_save = m2;
31 m1.swap(m2);
32 assert(m1 == m2_save);
33 assert(m2 == m1_save);
36 V ar2[] =
43 10,
44 11,
47 M m1;
48 M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
49 M m1_save = m1;
50 M m2_save = m2;
51 m1.swap(m2);
52 assert(m1 == m2_save);
53 assert(m2 == m1_save);
56 V ar1[] =
63 M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
64 M m2;
65 M m1_save = m1;
66 M m2_save = m2;
67 m1.swap(m2);
68 assert(m1 == m2_save);
69 assert(m2 == m1_save);
72 V ar1[] =
79 V ar2[] =
86 10,
87 11,
90 M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
91 M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
92 M m1_save = m1;
93 M m2_save = m2;
94 m1.swap(m2);
95 assert(m1 == m2_save);
96 assert(m2 == m1_save);
99 #if TEST_STD_VER >= 11
101 typedef int V;
102 typedef std::set<int, std::less<int>, min_allocator<int>> M;
104 M m1;
105 M m2;
106 M m1_save = m1;
107 M m2_save = m2;
108 m1.swap(m2);
109 assert(m1 == m2_save);
110 assert(m2 == m1_save);
113 V ar2[] =
124 M m1;
125 M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
126 M m1_save = m1;
127 M m2_save = m2;
128 m1.swap(m2);
129 assert(m1 == m2_save);
130 assert(m2 == m1_save);
133 V ar1[] =
140 M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
141 M m2;
142 M m1_save = m1;
143 M m2_save = m2;
144 m1.swap(m2);
145 assert(m1 == m2_save);
146 assert(m2 == m1_save);
149 V ar1[] =
156 V ar2[] =
167 M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
168 M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
169 M m1_save = m1;
170 M m2_save = m2;
171 m1.swap(m2);
172 assert(m1 == m2_save);
173 assert(m2 == m1_save);
176 #endif
178 return 0;