1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2011-2013 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>
27 struct hintable_allocator
30 struct const_void_pointer { };
31 typedef unsigned size_type;
33 hintable_allocator() : called(false) { }
37 // this is the overload that should get called:
38 T* allocate(size_type n, const_void_pointer) { called = true; return 0; }
40 // none of these should get called:
41 T* allocate(size_type n);
42 T* allocate(size_type n, void*);
43 T* allocate(size_type n, const void*);
44 T* allocate(size_type n, const_void_pointer) const;
49 bool test __attribute__((unused)) = true;
51 typedef std::allocator_traits<hintable_allocator<X>> traits_type;
52 traits_type::allocator_type a;
53 traits_type::const_void_pointer v;
54 X* p __attribute__((unused)) = traits_type::allocate(a, 1, v);
59 struct unhintable_allocator
62 typedef unsigned size_type;
64 unhintable_allocator() : called(false) { }
68 // this is the overload that should get called:
69 T* allocate(size_type n) { called = true; return 0; }
71 // this should not get called:
72 T* allocate(size_type n, void*);
77 bool test __attribute__((unused)) = true;
79 typedef std::allocator_traits<unhintable_allocator<X>> traits_type;
80 traits_type::allocator_type a;
81 traits_type::const_void_pointer v;
82 X* p __attribute__((unused)) = traits_type::allocate(a, 1, v);