]>
Commit | Line | Data |
---|---|---|
5bb89e0a JW |
1 | // Copyright (C) 2019 Free Software Foundation, Inc. |
2 | // | |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-options "-std=gnu++17" } | |
19 | // { dg-do compile { target c++17 } } | |
20 | ||
21 | #include <queue> | |
22 | #include <deque> | |
23 | #include <vector> | |
24 | #include <testsuite_iterators.h> | |
25 | ||
26 | template<typename T, typename U> struct require_same; | |
27 | template<typename T> struct require_same<T, T> { using type = void; }; | |
28 | ||
29 | template<typename T, typename U> | |
30 | typename require_same<T, U>::type | |
31 | check_type(U&) { } | |
32 | ||
33 | void | |
34 | test01() | |
35 | { | |
36 | std::priority_queue<unsigned> s0; | |
37 | ||
38 | std::priority_queue s1 = s0; | |
39 | check_type<std::priority_queue<unsigned>>(s1); | |
40 | ||
41 | std::priority_queue s2 = std::move(s0); | |
42 | check_type<std::priority_queue<unsigned>>(s2); | |
43 | ||
44 | const std::priority_queue s3 = s0; | |
45 | check_type<const std::priority_queue<unsigned>>(s3); | |
46 | ||
47 | const std::priority_queue s4 = s3; | |
48 | check_type<const std::priority_queue<unsigned>>(s4); | |
49 | ||
50 | std::allocator<unsigned> a; | |
51 | std::priority_queue s5(s0, a); | |
52 | check_type<std::priority_queue<unsigned>>(s5); | |
53 | ||
54 | std::priority_queue s6(std::move(s0), a); | |
55 | check_type<std::priority_queue<unsigned>>(s6); | |
56 | ||
57 | const std::priority_queue s7(s3, a); | |
58 | check_type<const std::priority_queue<unsigned>>(s7); | |
59 | } | |
60 | ||
61 | template<typename T> | |
62 | using input_iterator_seq | |
63 | = __gnu_test::test_container<T, __gnu_test::input_iterator_wrapper>; | |
64 | ||
65 | void | |
66 | test02() | |
67 | { | |
68 | using Deque = std::deque<int>; | |
69 | Deque d; | |
70 | using Vector = std::vector<short>; | |
71 | Vector v; | |
72 | using Cmp = std::greater<long>; | |
73 | Cmp cmp; | |
74 | ||
75 | std::priority_queue s1(cmp, d); | |
76 | check_type<std::priority_queue<int, Deque, Cmp>>(s1); | |
77 | ||
78 | std::priority_queue s2(cmp, d, d.get_allocator()); | |
79 | check_type<std::priority_queue<int, Deque, Cmp>>(s2); | |
80 | ||
81 | std::priority_queue s3(cmp, std::move(d)); | |
82 | check_type<std::priority_queue<int, Deque, Cmp>>(s3); | |
83 | ||
84 | std::priority_queue s4(cmp, std::move(d), d.get_allocator()); | |
85 | check_type<std::priority_queue<int, Deque, Cmp>>(s4); | |
86 | ||
87 | std::priority_queue s5(cmp, v); | |
88 | check_type<std::priority_queue<short, Vector, Cmp>>(s5); | |
89 | ||
90 | std::priority_queue s6(cmp, v, v.get_allocator()); | |
91 | check_type<std::priority_queue<short, Vector, Cmp>>(s6); | |
92 | ||
93 | std::priority_queue s7(cmp, std::move(v)); | |
94 | check_type<std::priority_queue<short, Vector, Cmp>>(s7); | |
95 | ||
96 | std::priority_queue s8(cmp, std::move(v), v.get_allocator()); | |
97 | check_type<std::priority_queue<short, Vector, Cmp>>(s8); | |
98 | ||
99 | short a[1] = {}; | |
100 | input_iterator_seq<short> seq(a); | |
101 | ||
102 | std::priority_queue s9(seq.begin(), seq.end()); | |
103 | check_type<std::priority_queue<short>>(s9); | |
104 | ||
105 | std::priority_queue s10(seq.begin(), seq.end(), {}); | |
106 | check_type<std::priority_queue<short>>(s10); | |
107 | ||
108 | std::priority_queue s11(seq.begin(), seq.end(), {}, {}); | |
109 | check_type<std::priority_queue<short>>(s11); | |
110 | ||
111 | std::priority_queue s12(seq.begin(), seq.end(), cmp); | |
112 | check_type<std::priority_queue<short, Vector, Cmp>>(s12); | |
113 | ||
114 | std::priority_queue s13(seq.begin(), seq.end(), cmp, {}); | |
115 | check_type<std::priority_queue<short, Vector, Cmp>>(s13); | |
116 | ||
117 | std::priority_queue s14(seq.begin(), seq.end(), cmp, std::deque<short>{}); | |
118 | check_type<std::priority_queue<short, std::deque<short>, Cmp>>(s14); | |
119 | } |