1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2011-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
22 #include <testsuite_hooks.h>
33 struct allocator_with_destroy
37 allocator_with_destroy() : called() { }
39 void destroy(T
* p
) { called
= true; }
45 struct allocator_without_destroy
49 allocator_without_destroy() : called() { }
56 typedef std::allocator_traits
<allocator_with_destroy
<X
>> traits_type
;
57 traits_type::allocator_type a
;
59 traits_type::destroy(a
, p
);
61 VERIFY( X::counter
== 0 );
66 typedef std::allocator_traits
<allocator_without_destroy
<X
>> traits_type
;
67 traits_type::allocator_type a
;
69 X
* p
= ::new (static_cast<void*>(buf
)) X();
70 traits_type::destroy(a
, p
);
72 VERIFY( X::counter
== 1 );