1 // Copyright (C) 2016-2020 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-options "-std=gnu++17" }
19 // { dg-do run { target c++17 } }
21 #include <memory_resource>
26 do_not_copy() = default;
27 do_not_copy(const do_not_copy
&) { throw 1; }
37 using pair
= std::pair
<X
, int>;
38 std::pmr::polymorphic_allocator
<pair
> a
;
39 auto ptr
= a
.allocate(1);
40 a
.construct(ptr
, std::piecewise_construct
,
41 std::tuple
<do_not_copy
>{}, std::make_tuple(1));
49 using allocator_type
= std::pmr::polymorphic_allocator
<int>;
50 X(do_not_copy
&&, const allocator_type
&) { }
53 using pair
= std::pair
<X
, int>;
54 std::pmr::polymorphic_allocator
<pair
> a
;
55 auto ptr
= a
.allocate(1);
56 a
.construct(ptr
, std::piecewise_construct
,
57 std::tuple
<do_not_copy
>{}, std::make_tuple(1));
65 using allocator_type
= std::pmr::polymorphic_allocator
<int>;
66 X(std::allocator_arg_t
, const allocator_type
&, do_not_copy
&&) { }
69 using pair
= std::pair
<X
, int>;
70 std::pmr::polymorphic_allocator
<pair
> a
;
71 auto ptr
= a
.allocate(1);
72 a
.construct(ptr
, std::piecewise_construct
,
73 std::tuple
<do_not_copy
>{}, std::make_tuple(1));
82 using allocator_type
= std::pmr::polymorphic_allocator
<int>;
84 X(const X
&) { throw 1; }
85 X(const X
&, const allocator_type
&) { }
90 using allocator_type
= std::pmr::polymorphic_allocator
<int>;
93 Y(std::allocator_arg_t
, const allocator_type
&, const Y
&) { }
96 using pair_type
= std::pair
<X
, Y
>;
97 std::pmr::polymorphic_allocator
<pair_type
> a
;
98 auto ptr
= a
.allocate(1);
99 /* not const */ pair_type p
;
100 a
.construct(ptr
, p
); // LWG 2975
101 a
.deallocate(ptr
, 1);