1 // Copyright (C) 2019-2025 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-do compile { target c++17 } }
23 #include <testsuite_allocator.h>
25 template<typename T
, typename U
> struct require_same
;
26 template<typename T
> struct require_same
<T
, T
> { using type
= void; };
28 template<typename T
, typename U
>
29 typename require_same
<T
, U
>::type
35 std::queue
<unsigned> s0
;
38 check_type
<std::queue
<unsigned>>(s1
);
40 std::queue s2
= std::move(s0
);
41 check_type
<std::queue
<unsigned>>(s2
);
43 const std::queue s3
= s0
;
44 check_type
<const std::queue
<unsigned>>(s3
);
46 const std::queue s4
= s3
;
47 check_type
<const std::queue
<unsigned>>(s4
);
49 std::allocator
<unsigned> a
;
51 check_type
<std::queue
<unsigned>>(s5
);
53 std::queue
s6(std::move(s0
), a
);
54 check_type
<std::queue
<unsigned>>(s6
);
56 const std::queue
s7(s3
, a
);
57 check_type
<const std::queue
<unsigned>>(s7
);
63 std::deque
<unsigned> d
;
67 check_type
<std::queue
<unsigned>>(s1
);
69 std::queue
s2(d
, d
.get_allocator());
70 check_type
<std::queue
<unsigned>>(s2
);
72 std::queue
s3(std::move(d
));
73 check_type
<std::queue
<unsigned>>(s3
);
75 std::queue
s4(std::move(d
), d
.get_allocator());
76 check_type
<std::queue
<unsigned>>(s4
);
79 check_type
<std::queue
<long, std::list
<long>>>(s5
);
81 std::queue
s6(l
, l
.get_allocator());
82 check_type
<std::queue
<long, std::list
<long>>>(s6
);
84 std::queue
s7(std::move(l
));
85 check_type
<std::queue
<long, std::list
<long>>>(s7
);
87 std::queue
s8(std::move(l
), l
.get_allocator());
88 check_type
<std::queue
<long, std::list
<long>>>(s8
);
94 struct Alloc
: __gnu_test::SimpleAllocator
<T
>
99 Alloc(const Alloc
<U
>&) { }
105 // P1518R2 - Stop overconstraining allocators in container deduction guides.
106 // This is a C++23 feature but we support it for C++17 too.
108 using Deque
= std::deque
<unsigned, Alloc
<unsigned>>;
109 using List
= std::list
<long, Alloc
<long>>;
115 check_type
<std::queue
<unsigned, Deque
>>(q1
);
118 check_type
<std::queue
<long, List
>>(q2
);
120 std::queue
q3(q2
, p
);
121 check_type
<std::queue
<long, List
>>(q3
);