| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <queue> |
| 10 | |
| 11 | // template <class Alloc> |
| 12 | // priority_queue(const priority_queue& q, const Alloc& a); |
| 13 | |
| 14 | #include <queue> |
| 15 | #include <cassert> |
| 16 | |
| 17 | #include "test_macros.h" |
| 18 | |
| 19 | template <class C> |
| 20 | TEST_CONSTEXPR_CXX26 C make(int n) { |
| 21 | C c; |
| 22 | for (int i = 0; i < n; ++i) |
| 23 | c.push_back(i); |
| 24 | return c; |
| 25 | } |
| 26 | |
| 27 | #include "test_macros.h" |
| 28 | #include "test_allocator.h" |
| 29 | |
| 30 | template <class T> |
| 31 | struct Test : public std::priority_queue<T, std::vector<T, test_allocator<T> > > { |
| 32 | typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; |
| 33 | typedef typename base::container_type container_type; |
| 34 | typedef typename base::value_compare value_compare; |
| 35 | |
| 36 | TEST_CONSTEXPR_CXX26 explicit Test(const test_allocator<int>& a) : base(a) {} |
| 37 | TEST_CONSTEXPR_CXX26 Test(const value_compare& compare, const test_allocator<int>& a) : base(compare, c, a) {} |
| 38 | TEST_CONSTEXPR_CXX26 Test(const value_compare& compare, const container_type& container, const test_allocator<int>& a) |
| 39 | : base(compare, container, a) {} |
| 40 | TEST_CONSTEXPR_CXX26 Test(const Test& q, const test_allocator<int>& a) : base(q, a) {} |
| 41 | TEST_CONSTEXPR_CXX26 test_allocator<int> get_allocator() { return c.get_allocator(); } |
| 42 | |
| 43 | using base::c; |
| 44 | }; |
| 45 | |
| 46 | TEST_CONSTEXPR_CXX26 bool test() { |
| 47 | Test<int> qo(std::less<int>(), make<std::vector<int, test_allocator<int> > >(5), test_allocator<int>(2)); |
| 48 | Test<int> q(qo, test_allocator<int>(6)); |
| 49 | assert(q.size() == 5); |
| 50 | assert(q.c.get_allocator() == test_allocator<int>(6)); |
| 51 | assert(q.top() == int(4)); |
| 52 | |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | int main(int, char**) { |
| 57 | assert(test()); |
| 58 | #if TEST_STD_VER >= 26 |
| 59 | static_assert(test()); |
| 60 | #endif |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |