Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <list> |
| 11 | |
| 12 | // list(list&& c, const allocator_type& a); |
| 13 | |
| 14 | #include <list> |
| 15 | #include <cassert> |
| 16 | #include "../../../MoveOnly.h" |
| 17 | #include "../../../test_allocator.h" |
| 18 | |
| 19 | int main() |
| 20 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 21 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | { |
| 23 | std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); |
| 24 | std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); |
| 25 | for (int i = 1; i <= 3; ++i) |
| 26 | { |
| 27 | l.push_back(i); |
| 28 | lo.push_back(i); |
| 29 | } |
| 30 | std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6)); |
| 31 | assert(l2 == lo); |
| 32 | assert(!l.empty()); |
| 33 | assert(l2.get_allocator() == test_allocator<MoveOnly>(6)); |
| 34 | } |
| 35 | { |
| 36 | std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); |
| 37 | std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); |
| 38 | for (int i = 1; i <= 3; ++i) |
| 39 | { |
| 40 | l.push_back(i); |
| 41 | lo.push_back(i); |
| 42 | } |
| 43 | std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5)); |
| 44 | assert(l2 == lo); |
| 45 | assert(l.empty()); |
| 46 | assert(l2.get_allocator() == test_allocator<MoveOnly>(5)); |
| 47 | } |
| 48 | { |
| 49 | std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5)); |
| 50 | std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5)); |
| 51 | for (int i = 1; i <= 3; ++i) |
| 52 | { |
| 53 | l.push_back(i); |
| 54 | lo.push_back(i); |
| 55 | } |
| 56 | std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4)); |
| 57 | assert(l2 == lo); |
| 58 | assert(!l.empty()); |
| 59 | assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); |
| 60 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 61 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 62 | } |