]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc
1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2014-2016 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/>.
21 #include <testsuite_allocator.h>
23 // User-defined pointer type with non-trivial destructor.
25 struct Pointer
: __gnu_test::PointerBase
<Pointer
<T
>, T
>
27 using __gnu_test::PointerBase
<Pointer
<T
>, T
>::PointerBase
;
29 ~Pointer() { /* non-trivial */ }
32 // Minimal allocator with user-defined pointer type.
37 typedef Pointer
<T
> pointer
;
42 Alloc(const Alloc
<U
>&) { }
44 pointer
allocate(std::size_t n
) // does not take a hint
45 { return pointer(std::allocator
<T
>().allocate(n
)); }
47 void deallocate(pointer p
, std::size_t n
)
48 { std::allocator
<T
>().deallocate(p
.value
, n
); }
52 bool operator==(Alloc
<T
> l
, Alloc
<T
> r
) { return true; }
55 bool operator!=(Alloc
<T
> l
, Alloc
<T
> r
) { return false; }
59 typedef std::allocator_traits
<Alloc
<int>> traits_type
;
60 traits_type::allocator_type a
;
61 traits_type::const_void_pointer v
;
62 traits_type::pointer p
= traits_type::allocate(a
, 1, v
);
63 traits_type::deallocate(a
, p
, 1);