| 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 |
|
| 22 |
int main(int, char**) |
| 23 |
{ |
| 24 |
typedef std::vector<int, limited_allocator<int, 10> > Container; |
| 25 |
typedef std::less<int> Compare; |
| 26 |
typedef std::priority_queue<int, Container> Q; |
| 27 |
Q q((Compare())); |
| 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 |
static_assert(!test_convertible<Q, const Compare&>(), ""); |
| 36 |
#endif |
| 37 |
|
| 38 |
return 0; |
| 39 |
} |