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 | // <forward_list> |
| 11 | |
| 12 | // forward_list(forward_list&& x, const allocator_type& a); |
| 13 | |
| 14 | #include <forward_list> |
| 15 | #include <cassert> |
| 16 | #include <iterator> |
| 17 | |
| 18 | #include "../../../test_allocator.h" |
| 19 | #include "../../../MoveOnly.h" |
| 20 | |
| 21 | int main() |
| 22 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 23 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 24 | { |
| 25 | typedef MoveOnly T; |
| 26 | typedef test_allocator<int> A; |
| 27 | typedef std::forward_list<T, A> C; |
| 28 | T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 29 | typedef std::move_iterator<T*> I; |
| 30 | C c0(I(std::begin(t)), I(std::end(t)), A(10)); |
| 31 | C c(std::move(c0), A(10)); |
| 32 | unsigned n = 0; |
| 33 | for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) |
| 34 | assert(*i == n); |
| 35 | assert(n == std::end(t) - std::begin(t)); |
| 36 | assert(c0.empty()); |
| 37 | assert(c.get_allocator() == A(10)); |
| 38 | } |
| 39 | { |
| 40 | typedef MoveOnly T; |
| 41 | typedef test_allocator<int> A; |
| 42 | typedef std::forward_list<T, A> C; |
| 43 | T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 44 | typedef std::move_iterator<T*> I; |
| 45 | C c0(I(std::begin(t)), I(std::end(t)), A(10)); |
| 46 | C c(std::move(c0), A(9)); |
| 47 | unsigned n = 0; |
| 48 | for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) |
| 49 | assert(*i == n); |
| 50 | assert(n == std::end(t) - std::begin(t)); |
| 51 | assert(!c0.empty()); |
| 52 | assert(c.get_allocator() == A(9)); |
| 53 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 54 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | } |