1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2011 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/>.
20 // 20.6.7.2 uses-allocator construction
24 #include <testsuite_hooks.h>
28 // type that can't be constructed with an allocator
31 CannotUse(int) : ok(true) { }
36 // type that can be constructed with an allocator
37 // but which has uses_allocator == false
40 typedef MyAlloc allocator_type;
42 DoesNotUse(int) : ok(true) { }
43 DoesNotUse(std::allocator_arg_t, MyAlloc, int) : ok(false) { }
44 DoesNotUse(int, MyAlloc) : ok(false) { }
52 struct uses_allocator<DoesNotUse, A> : false_type { };
55 // type that can be constructed with an allocator as second argument
58 typedef MyAlloc allocator_type;
60 UsesWithTag(int) : ok(false) { }
61 UsesWithTag(std::allocator_arg_t, MyAlloc, int) : ok(true) { }
62 UsesWithTag(int, MyAlloc) : ok(false) { }
67 // type that can be constructed with an allocator as last argument
70 typedef MyAlloc allocator_type;
72 UsesWithoutTag(int) : ok(false) { }
73 UsesWithoutTag(int, MyAlloc) : ok(true) { }
79 template<typename TestType, typename... T>
82 using std::allocator_arg;
86 tuple<TestType, T...> t(allocator_arg, MyAlloc(), 1, args...);
91 template<typename... T>
94 bool test __attribute__((unused)) = true;
96 VERIFY( test2<CannotUse>(args...) );
97 VERIFY( test2<DoesNotUse>(args...) );
98 VERIFY( test2<UsesWithTag>(args...) );
99 VERIFY( test2<UsesWithoutTag>(args...) );