| 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 | // explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 |
| 12 | // priority_queue() : priority_queue(Compare()) {} // C++20 |
| 13 | // explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} // C++20 |
| 14 | |
| 15 | #include <queue> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "test_macros.h" |
| 19 | #include "test_allocator.h" |
| 20 | #if TEST_STD_VER >= 11 |
| 21 | # include "test_convertible.h" |
| 22 | #endif |
| 23 | |
| 24 | TEST_CONSTEXPR_CXX26 bool test() { |
| 25 | typedef std::vector<int, limited_allocator<int, 10> > Container; |
| 26 | typedef std::priority_queue<int, Container> Q; |
| 27 | Q q; |
| 28 | assert(q.size() == 0); |
| 29 | q.push(1); |
| 30 | q.push(2); |
| 31 | assert(q.size() == 2); |
| 32 | assert(q.top() == 2); |
| 33 | |
| 34 | #if TEST_STD_VER >= 11 |
| 35 | // It should be explicit, so not convertible before C++20. |
| 36 | static_assert(test_convertible<Q>(), "" ); |
| 37 | #endif |
| 38 | |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | int main(int, char**) { |
| 43 | assert(test()); |
| 44 | #if TEST_STD_VER >= 26 |
| 45 | static_assert(test()); |
| 46 | #endif |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |