| 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 | // explicit priority_queue(const Alloc& a); |
| 13 | |
| 14 | #include <queue> |
| 15 | #include <cassert> |
| 16 | |
| 17 | #include "test_macros.h" |
| 18 | #include "test_allocator.h" |
| 19 | |
| 20 | template <class T> |
| 21 | struct Test : public std::priority_queue<T, std::vector<T, test_allocator<T> > > { |
| 22 | typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; |
| 23 | typedef typename base::container_type container_type; |
| 24 | typedef typename base::value_compare value_compare; |
| 25 | |
| 26 | TEST_CONSTEXPR_CXX26 explicit Test(const test_allocator<int>& a) : base(a) {} |
| 27 | TEST_CONSTEXPR_CXX26 Test(const value_compare& comp, const test_allocator<int>& a) : base(comp, c, a) {} |
| 28 | TEST_CONSTEXPR_CXX26 Test(const value_compare& comp, const container_type& container, const test_allocator<int>& a) |
| 29 | : base(comp, container, a) {} |
| 30 | #if TEST_STD_VER >= 11 |
| 31 | TEST_CONSTEXPR_CXX26 Test(const value_compare& comp, container_type&& container, const test_allocator<int>& a) |
| 32 | : base(comp, std::move(container), a) {} |
| 33 | TEST_CONSTEXPR_CXX26 Test(Test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} |
| 34 | #endif |
| 35 | TEST_CONSTEXPR_CXX26 test_allocator<int> get_allocator() { return c.get_allocator(); } |
| 36 | |
| 37 | using base::c; |
| 38 | }; |
| 39 | |
| 40 | TEST_CONSTEXPR_CXX26 bool test() { |
| 41 | Test<int> q((test_allocator<int>(3))); |
| 42 | assert(q.c.get_allocator() == test_allocator<int>(3)); |
| 43 | assert(q.c.size() == 0); |
| 44 | |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | int main(int, char**) { |
| 49 | assert(test()); |
| 50 | #if TEST_STD_VER >= 26 |
| 51 | static_assert(test()); |
| 52 | #endif |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |