1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <forward_list> 11 12 // forward_list& operator=(const forward_list& x); 13 14 #include <forward_list> 15 #include <cassert> 16 #include <iterator> 17 18 #include "test_allocator.h" 19 #include "min_allocator.h" 20 21 int main() 22 { 23 { 24 typedef int T; 25 typedef test_allocator<int> A; 26 typedef std::forward_list<T, A> C; 27 const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 28 const T t1[] = {10, 11, 12, 13}; 29 C c0(std::begin(t0), std::end(t0), A(10)); 30 C c1(std::begin(t1), std::end(t1), A(10)); 31 c1 = c0; 32 assert(c1 == c0); 33 assert(c1.get_allocator() == A(10)); 34 } 35 { 36 typedef int T; 37 typedef test_allocator<int> A; 38 typedef std::forward_list<T, A> C; 39 const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 40 const T t1[] = {10, 11, 12, 13}; 41 C c0(std::begin(t0), std::end(t0), A(10)); 42 C c1(std::begin(t1), std::end(t1), A(11)); 43 c1 = c0; 44 assert(c1 == c0); 45 assert(c1.get_allocator() == A(11)); 46 } 47 { 48 typedef int T; 49 typedef test_allocator<int> A; 50 typedef std::forward_list<T, A> C; 51 const T t0[] = {10, 11, 12, 13}; 52 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 53 C c0(std::begin(t0), std::end(t0), A(10)); 54 C c1(std::begin(t1), std::end(t1), A(10)); 55 c1 = c0; 56 assert(c1 == c0); 57 assert(c1.get_allocator() == A(10)); 58 } 59 { 60 typedef int T; 61 typedef test_allocator<int> A; 62 typedef std::forward_list<T, A> C; 63 const T t0[] = {10, 11, 12, 13}; 64 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 65 C c0(std::begin(t0), std::end(t0), A(10)); 66 C c1(std::begin(t1), std::end(t1), A(11)); 67 c1 = c0; 68 assert(c1 == c0); 69 assert(c1.get_allocator() == A(11)); 70 } 71 72 { 73 typedef int T; 74 typedef other_allocator<int> A; 75 typedef std::forward_list<T, A> C; 76 const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 77 const T t1[] = {10, 11, 12, 13}; 78 C c0(std::begin(t0), std::end(t0), A(10)); 79 C c1(std::begin(t1), std::end(t1), A(10)); 80 c1 = c0; 81 assert(c1 == c0); 82 assert(c1.get_allocator() == A(10)); 83 } 84 { 85 typedef int T; 86 typedef other_allocator<int> A; 87 typedef std::forward_list<T, A> C; 88 const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 89 const T t1[] = {10, 11, 12, 13}; 90 C c0(std::begin(t0), std::end(t0), A(10)); 91 C c1(std::begin(t1), std::end(t1), A(11)); 92 c1 = c0; 93 assert(c1 == c0); 94 assert(c1.get_allocator() == A(10)); 95 } 96 { 97 typedef int T; 98 typedef other_allocator<int> A; 99 typedef std::forward_list<T, A> C; 100 const T t0[] = {10, 11, 12, 13}; 101 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 102 C c0(std::begin(t0), std::end(t0), A(10)); 103 C c1(std::begin(t1), std::end(t1), A(10)); 104 c1 = c0; 105 assert(c1 == c0); 106 assert(c1.get_allocator() == A(10)); 107 } 108 { 109 typedef int T; 110 typedef other_allocator<int> A; 111 typedef std::forward_list<T, A> C; 112 const T t0[] = {10, 11, 12, 13}; 113 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 114 C c0(std::begin(t0), std::end(t0), A(10)); 115 C c1(std::begin(t1), std::end(t1), A(11)); 116 c1 = c0; 117 assert(c1 == c0); 118 assert(c1.get_allocator() == A(10)); 119 } 120 #if __cplusplus >= 201103L 121 { 122 typedef int T; 123 typedef min_allocator<int> A; 124 typedef std::forward_list<T, A> C; 125 const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 126 const T t1[] = {10, 11, 12, 13}; 127 C c0(std::begin(t0), std::end(t0), A()); 128 C c1(std::begin(t1), std::end(t1), A()); 129 c1 = c0; 130 assert(c1 == c0); 131 assert(c1.get_allocator() == A()); 132 } 133 { 134 typedef int T; 135 typedef min_allocator<int> A; 136 typedef std::forward_list<T, A> C; 137 const T t0[] = {10, 11, 12, 13}; 138 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 139 C c0(std::begin(t0), std::end(t0), A()); 140 C c1(std::begin(t1), std::end(t1), A()); 141 c1 = c0; 142 assert(c1 == c0); 143 assert(c1.get_allocator() == A()); 144 } 145 #endif 146 } 147