| 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 | // UNSUPPORTED: c++03, c++11, c++14 |
| 11 | |
| 12 | #include <queue> |
| 13 | #include <deque> |
| 14 | #include <iterator> |
| 15 | #include <cassert> |
| 16 | #include <cstddef> |
| 17 | |
| 18 | int main(int, char**) { |
| 19 | // Test the explicit deduction guides |
| 20 | { |
| 21 | // queue(Compare, Container, const Alloc); |
| 22 | // The '45' is not an allocator |
| 23 | std::priority_queue pri(std::greater<int>(), std::deque<int>({1, 2, 3}), 45); |
| 24 | // expected-error-re@-1 {{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}priority_queue'}} |
| 25 | } |
| 26 | |
| 27 | { |
| 28 | // queue(const queue&, const Alloc&); |
| 29 | // The '45' is not an allocator |
| 30 | std::priority_queue<int> source; |
| 31 | std::priority_queue pri(source, 45); |
| 32 | // expected-error-re@-1 {{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}priority_queue'}} |
| 33 | } |
| 34 | |
| 35 | { |
| 36 | // priority_queue(Iter, Iter, Comp) |
| 37 | // int is not an iterator |
| 38 | std::priority_queue pri(15, 17, std::greater< double>()); |
| 39 | // expected-error-re@-1 {{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}priority_queue'}} |
| 40 | } |
| 41 | |
| 42 | { |
| 43 | // priority_queue(Iter, Iter, Comp, Container) |
| 44 | // float is not an iterator |
| 45 | std::priority_queue pri(23.f, 2.f, std::greater<float>(), std::deque< float>()); |
| 46 | // expected-error-re@-1 {{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}priority_queue'}} |
| 47 | } |
| 48 | |
| 49 | // Test the implicit deduction guides |
| 50 | { |
| 51 | // priority_queue (allocator &) |
| 52 | std::priority_queue pri((std::allocator< int>())); |
| 53 | // expected-error-re@-1 {{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}priority_queue'}} |
| 54 | // Note: The extra parens are necessary, since otherwise clang decides it is a function declaration. |
| 55 | // Also, we can't use {} instead of parens, because that constructs a |
| 56 | // stack<allocator<int>, allocator<allocator<int>>> |
| 57 | } |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |