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