1 // Copyright (C) 2016-2018 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 run { target c++11 } }
22 #include <scoped_allocator>
25 do_not_copy() = default;
26 do_not_copy(const do_not_copy
&) { throw 1; }
36 using pair
= std::pair
<X
, int>;
37 std::scoped_allocator_adaptor
<std::allocator
<pair
>> a
;
38 auto ptr
= a
.allocate(1);
39 a
.construct(ptr
, std::piecewise_construct
,
40 std::tuple
<do_not_copy
>{}, std::make_tuple(1));
48 using allocator_type
= std::allocator
<int>;
49 X(do_not_copy
&&, const allocator_type
&) { }
52 using pair
= std::pair
<X
, int>;
53 std::scoped_allocator_adaptor
<std::allocator
<pair
>> a
;
54 auto ptr
= a
.allocate(1);
55 a
.construct(ptr
, std::piecewise_construct
,
56 std::tuple
<do_not_copy
>{}, std::make_tuple(1));
64 using allocator_type
= std::allocator
<int>;
65 X(std::allocator_arg_t
, const allocator_type
&, do_not_copy
&&) { }
68 using pair
= std::pair
<X
, int>;
69 std::scoped_allocator_adaptor
<std::allocator
<pair
>> a
;
70 auto ptr
= a
.allocate(1);
71 a
.construct(ptr
, std::piecewise_construct
,
72 std::tuple
<do_not_copy
>{}, std::make_tuple(1));
81 using allocator_type
= std::allocator
<int>;
83 X(const X
&) { throw 1; }
84 X(const X
&, const allocator_type
&) { }
89 using allocator_type
= std::allocator
<int>;
92 Y(std::allocator_arg_t
, const allocator_type
&, const Y
&) { }
95 using pair_type
= std::pair
<X
, Y
>;
96 std::scoped_allocator_adaptor
<std::allocator
<pair_type
>> a
;
97 auto ptr
= a
.allocate(1);
98 /* not const */ pair_type p
;
99 a
.construct(ptr
, p
); // LWG 2975
100 a
.deallocate(ptr
, 1);