Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame^] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <set> |
| 11 | |
| 12 | // class set |
| 13 | |
| 14 | // set& operator=(set&& s); |
| 15 | |
| 16 | #include <set> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "../../../MoveOnly.h" |
| 20 | #include "../../../test_compare.h" |
| 21 | #include "../../../test_allocator.h" |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | #ifdef _LIBCPP_MOVE |
| 26 | { |
| 27 | typedef MoveOnly V; |
| 28 | typedef test_compare<std::less<MoveOnly> > C; |
| 29 | typedef test_allocator<V> A; |
| 30 | typedef std::set<MoveOnly, C, A> M; |
| 31 | typedef std::move_iterator<V*> I; |
| 32 | V a1[] = |
| 33 | { |
| 34 | V(1), |
| 35 | V(1), |
| 36 | V(1), |
| 37 | V(2), |
| 38 | V(2), |
| 39 | V(2), |
| 40 | V(3), |
| 41 | V(3), |
| 42 | V(3) |
| 43 | }; |
| 44 | M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7)); |
| 45 | V a2[] = |
| 46 | { |
| 47 | V(1), |
| 48 | V(1), |
| 49 | V(1), |
| 50 | V(2), |
| 51 | V(2), |
| 52 | V(2), |
| 53 | V(3), |
| 54 | V(3), |
| 55 | V(3) |
| 56 | }; |
| 57 | M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7)); |
| 58 | M m3(C(3), A(7)); |
| 59 | m3 = std::move(m1); |
| 60 | assert(m3 == m2); |
| 61 | assert(m3.get_allocator() == A(7)); |
| 62 | assert(m3.key_comp() == C(5)); |
| 63 | assert(m1.empty()); |
| 64 | } |
| 65 | { |
| 66 | typedef MoveOnly V; |
| 67 | typedef test_compare<std::less<MoveOnly> > C; |
| 68 | typedef test_allocator<V> A; |
| 69 | typedef std::set<MoveOnly, C, A> M; |
| 70 | typedef std::move_iterator<V*> I; |
| 71 | V a1[] = |
| 72 | { |
| 73 | V(1), |
| 74 | V(1), |
| 75 | V(1), |
| 76 | V(2), |
| 77 | V(2), |
| 78 | V(2), |
| 79 | V(3), |
| 80 | V(3), |
| 81 | V(3) |
| 82 | }; |
| 83 | M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7)); |
| 84 | V a2[] = |
| 85 | { |
| 86 | V(1), |
| 87 | V(1), |
| 88 | V(1), |
| 89 | V(2), |
| 90 | V(2), |
| 91 | V(2), |
| 92 | V(3), |
| 93 | V(3), |
| 94 | V(3) |
| 95 | }; |
| 96 | M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7)); |
| 97 | M m3(C(3), A(5)); |
| 98 | m3 = std::move(m1); |
| 99 | assert(m3 == m2); |
| 100 | assert(m3.get_allocator() == A(5)); |
| 101 | assert(m3.key_comp() == C(5)); |
| 102 | assert(m1.empty()); |
| 103 | } |
| 104 | { |
| 105 | typedef MoveOnly V; |
| 106 | typedef test_compare<std::less<MoveOnly> > C; |
| 107 | typedef other_allocator<V> A; |
| 108 | typedef std::set<MoveOnly, C, A> M; |
| 109 | typedef std::move_iterator<V*> I; |
| 110 | V a1[] = |
| 111 | { |
| 112 | V(1), |
| 113 | V(1), |
| 114 | V(1), |
| 115 | V(2), |
| 116 | V(2), |
| 117 | V(2), |
| 118 | V(3), |
| 119 | V(3), |
| 120 | V(3) |
| 121 | }; |
| 122 | M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7)); |
| 123 | V a2[] = |
| 124 | { |
| 125 | V(1), |
| 126 | V(1), |
| 127 | V(1), |
| 128 | V(2), |
| 129 | V(2), |
| 130 | V(2), |
| 131 | V(3), |
| 132 | V(3), |
| 133 | V(3) |
| 134 | }; |
| 135 | M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7)); |
| 136 | M m3(C(3), A(5)); |
| 137 | m3 = std::move(m1); |
| 138 | assert(m3 == m2); |
| 139 | assert(m3.get_allocator() == A(7)); |
| 140 | assert(m3.key_comp() == C(5)); |
| 141 | assert(m1.empty()); |
| 142 | } |
| 143 | #endif |
| 144 | } |