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 | // <queue> |
| 11 | |
| 12 | // template <class Alloc> |
| 13 | // queue(queue&& q, const Alloc& a); |
| 14 | |
| 15 | #include <queue> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "../../../../test_allocator.h" |
| 19 | #include "../../../../MoveOnly.h" |
| 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 | template <class C> |
| 24 | C |
| 25 | make(int n) |
| 26 | { |
| 27 | C c; |
| 28 | for (int i = 0; i < n; ++i) |
| 29 | c.push_back(MoveOnly(i)); |
| 30 | return c; |
| 31 | } |
| 32 | |
| 33 | typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C; |
| 34 | |
| 35 | template <class T> |
| 36 | struct test |
| 37 | : public std::queue<T, C> |
| 38 | { |
| 39 | typedef std::queue<T, C> base; |
| 40 | typedef test_allocator<MoveOnly> allocator_type; |
| 41 | typedef typename base::container_type container_type; |
| 42 | |
| 43 | explicit test(const allocator_type& a) : base(a) {} |
| 44 | test(const container_type& c, const allocator_type& a) : base(c, a) {} |
| 45 | test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {} |
| 46 | test(test&& q, const allocator_type& a) : base(std::move(q), a) {} |
| 47 | allocator_type get_allocator() {return this->c.get_allocator();} |
| 48 | }; |
| 49 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 50 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 51 | |
| 52 | int main() |
| 53 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 54 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); |
| 56 | test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5)); |
| 57 | assert(q2.get_allocator() == test_allocator<MoveOnly>(5)); |
| 58 | assert(q2.size() == 5); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 59 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | } |