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 // <list>
10
11 // void merge(list& x);
12 // If (addressof(x) == this) does nothing; otherwise ...
13
14 #include <list>
15 #include <cassert>
16
17 #include "test_macros.h"
18 #include "min_allocator.h"
19
main(int,char **)20 int main(int, char**)
21 {
22 {
23 int a1[] = {1, 3, 7, 9, 10};
24 int a2[] = {0, 2, 4, 5, 6, 8, 11};
25 int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
26 std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
27 std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
28 c1.merge(c2);
29 assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
30 assert(c2.empty());
31 }
32
33 {
34 int a1[] = {1, 3, 7, 9, 10};
35 std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
36 c1.merge(c1);
37 assert((c1 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
38 }
39
40 #if TEST_STD_VER >= 11
41 {
42 int a1[] = {1, 3, 7, 9, 10};
43 int a2[] = {0, 2, 4, 5, 6, 8, 11};
44 int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
45 std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
46 std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
47 c1.merge(c2);
48 assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
49 assert(c2.empty());
50 }
51 #endif
52
53 return 0;
54 }
55