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

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