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// UNSUPPORTED: c++03
10
11// <queue>
12
13// explicit priority_queue(const Compare& comp, Container&& c); // before C++20
14// priority_queue(const Compare& comp, Container&& c); // C++20
15
16#include <queue>
17#include <cassert>
18
19#include "test_macros.h"
20#include "MoveOnly.h"
21#include "test_convertible.h"
22
23template <class C>
24TEST_CONSTEXPR_CXX26 C make(int n) {
25 C c;
26 for (int i = 0; i < n; ++i)
27 c.push_back(MoveOnly(i));
28 return c;
29}
30
31TEST_CONSTEXPR_CXX26 bool test() {
32 typedef std::vector<MoveOnly> Container;
33 typedef std::less<MoveOnly> Compare;
34 typedef std::priority_queue<MoveOnly> Q;
35 Q q(Compare(), make<Container>(5));
36 assert(q.size() == 5);
37 assert(q.top() == MoveOnly(4));
38 static_assert(test_convertible<Q, const Compare&, Container&&>(), "");
39
40 return true;
41}
42
43int main(int, char**) {
44 assert(test());
45#if TEST_STD_VER >= 26
46 static_assert(test());
47#endif
48
49 return 0;
50}
51

source code of libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp