2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / libstdc++-v3 / testsuite / util / testsuite_common_types.h
blob35bd907d8da46c95537bd53290056724c9b59713
1 // -*- C++ -*-
2 // typelist for the C++ library testsuite.
3 //
4 // Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 #ifndef _TESTSUITE_COMMON_TYPES_H
32 #define _TESTSUITE_COMMON_TYPES_H 1
34 #include <ext/typelist.h>
36 #include <ext/new_allocator.h>
37 #include <ext/malloc_allocator.h>
38 #include <ext/mt_allocator.h>
39 #include <ext/bitmap_allocator.h>
40 #include <ext/pool_allocator.h>
42 #include <algorithm>
44 #include <vector>
45 #include <list>
46 #include <deque>
47 #include <string>
49 #include <map>
50 #include <set>
51 #include <tr1/functional>
52 #include <tr1/unordered_map>
53 #include <tr1/unordered_set>
55 #ifdef __GXX_EXPERIMENTAL_CXX0X__
56 #include <cstdatomic>
57 #endif
59 namespace __gnu_test
61 using __gnu_cxx::typelist::node;
62 using __gnu_cxx::typelist::transform;
63 using __gnu_cxx::typelist::append;
65 // All the allocators to test.
66 template<typename Tp, bool Thread>
67 struct allocator_policies
69 typedef Tp value_type;
70 typedef __gnu_cxx::new_allocator<Tp> a1;
71 typedef __gnu_cxx::malloc_allocator<Tp> a2;
72 typedef __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, Thread> pool_policy;
73 typedef __gnu_cxx::__mt_alloc<Tp, pool_policy> a3;
74 typedef __gnu_cxx::bitmap_allocator<Tp> a4;
75 typedef __gnu_cxx::__pool_alloc<Tp> a5;
76 typedef node<_GLIBCXX_TYPELIST_CHAIN5(a1, a2, a3, a4, a5)> type;
79 // Typelists for vector, string, list, deque.
80 // XXX should just use template templates
81 template<typename Tp, bool Thread>
82 struct vectors
84 typedef Tp value_type;
86 template<typename Tl>
87 struct vector_shell
89 typedef Tl allocator_type;
90 typedef std::vector<value_type, allocator_type> type;
93 typedef allocator_policies<value_type, Thread> allocator_types;
94 typedef typename allocator_types::type allocator_typelist;
95 typedef typename transform<allocator_typelist, vector_shell>::type type;
98 template<typename Tp, bool Thread>
99 struct lists
101 typedef Tp value_type;
103 template<typename Tl>
104 struct list_shell
106 typedef Tl allocator_type;
107 typedef std::list<value_type, allocator_type> type;
110 typedef allocator_policies<value_type, Thread> allocator_types;
111 typedef typename allocator_types::type allocator_typelist;
112 typedef typename transform<allocator_typelist, list_shell>::type type;
115 template<typename Tp, bool Thread>
116 struct deques
118 typedef Tp value_type;
120 template<typename Tl>
121 struct deque_shell
123 typedef Tl allocator_type;
124 typedef std::deque<value_type, allocator_type> type;
127 typedef allocator_policies<value_type, Thread> allocator_types;
128 typedef typename allocator_types::type allocator_typelist;
129 typedef typename transform<allocator_typelist, deque_shell>::type type;
132 template<typename Tp, bool Thread>
133 struct strings
135 typedef Tp value_type;
137 template<typename Tl>
138 struct string_shell
140 typedef Tl allocator_type;
141 typedef std::char_traits<value_type> traits_type;
142 typedef std::basic_string<value_type, traits_type, allocator_type> type;
145 typedef allocator_policies<value_type, Thread> allocator_types;
146 typedef typename allocator_types::type allocator_typelist;
147 typedef typename transform<allocator_typelist, string_shell>::type type;
150 // A typelist of vector, list, deque, and string all instantiated
151 // with each of the allocator policies.
152 template<typename Tp, bool Thread>
153 struct sequence_containers
155 typedef Tp value_type;
157 typedef typename vectors<value_type, Thread>::type vector_typelist;
158 typedef typename lists<value_type, Thread>::type list_typelist;
159 typedef typename deques<value_type, Thread>::type deque_typelist;
160 typedef typename strings<value_type, Thread>::type string_typelist;
162 typedef typename append<vector_typelist, list_typelist>::type a1;
163 typedef typename append<deque_typelist, string_typelist>::type a2;
164 typedef typename append<a1, a2>::type type;
167 // Typelists for map, set, unordered_set, unordered_map.
168 template<typename Tp, bool Thread>
169 struct maps
171 typedef Tp value_type;
172 typedef Tp key_type;
173 typedef std::pair<const key_type, value_type> pair_type;
174 typedef std::less<key_type> compare_function;
176 template<typename Tl>
177 struct container
179 typedef Tl allocator_type;
180 typedef std::map<key_type, value_type, compare_function, allocator_type> type;
183 typedef allocator_policies<pair_type, Thread> allocator_types;
184 typedef typename allocator_types::type allocator_typelist;
185 typedef typename transform<allocator_typelist, container>::type type;
188 template<typename Tp, bool Thread>
189 struct unordered_maps
191 typedef Tp value_type;
192 typedef Tp key_type;
193 typedef std::pair<const key_type, value_type> pair_type;
194 typedef std::tr1::hash<key_type> hash_function;
195 typedef std::equal_to<key_type> equality_function;
197 template<typename Tl>
198 struct container
200 typedef Tl allocator_type;
201 typedef std::tr1::unordered_map<key_type, value_type, hash_function, equality_function, allocator_type> type;
204 typedef allocator_policies<pair_type, Thread> allocator_types;
205 typedef typename allocator_types::type allocator_typelist;
206 typedef typename transform<allocator_typelist, container>::type type;
209 template<typename Tp, bool Thread>
210 struct sets
212 typedef Tp value_type;
213 typedef Tp key_type;
214 typedef std::less<key_type> compare_function;
216 template<typename Tl>
217 struct container
219 typedef Tl allocator_type;
220 typedef std::set<key_type, compare_function, allocator_type> type;
223 typedef allocator_policies<key_type, Thread> allocator_types;
224 typedef typename allocator_types::type allocator_typelist;
225 typedef typename transform<allocator_typelist, container>::type type;
228 template<typename Tp, bool Thread>
229 struct unordered_sets
231 typedef Tp value_type;
232 typedef Tp key_type;
233 typedef std::tr1::hash<key_type> hash_function;
234 typedef std::equal_to<key_type> equality_function;
236 template<typename Tl>
237 struct container
239 typedef Tl allocator_type;
240 typedef std::tr1::unordered_set<key_type, hash_function, equality_function, allocator_type> type;
243 typedef allocator_policies<key_type, Thread> allocator_types;
244 typedef typename allocator_types::type allocator_typelist;
245 typedef typename transform<allocator_typelist, container>::type type;
249 // A typelist of all associated container types, with each of the
250 // allocator policies.
251 template<typename Tp, bool Thread>
252 struct associative_containers
254 typedef Tp value_type;
256 typedef typename maps<value_type, Thread>::type map_typelist;
257 typedef typename sets<value_type, Thread>::type set_typelist;
258 typedef typename unordered_maps<value_type, Thread>::type unordered_map_typelist;
259 typedef typename unordered_sets<value_type, Thread>::type unordered_set_typelist;
261 typedef typename append<map_typelist, unordered_map_typelist>::type a1;
262 typedef typename append<set_typelist, unordered_set_typelist>::type a2;
263 typedef typename append<a1, a2>::type type;
266 // A typelist of all integral types.
267 struct integral_types
269 typedef bool a1;
270 typedef char a2;
271 typedef signed char a3;
272 typedef unsigned char a4;
273 typedef short a5;
274 typedef unsigned short a6;
275 typedef int a7;
276 typedef unsigned int a8;
277 typedef long a9;
278 typedef unsigned long a10;
279 typedef long long a11;
280 typedef unsigned long long a12;
281 typedef wchar_t a13;
282 // typedef char16_t a14;
283 // typedef char16_t a15;
285 typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
286 a10, a11, a12, a13)> type;
289 #ifdef __GXX_EXPERIMENTAL_CXX0X__
290 template<typename Tp>
291 struct atomics
293 typedef Tp value_type;
294 typedef std::atomic<value_type> type;
297 typedef transform<integral_types::type, atomics>::type atomics_tl;
298 #endif
300 // Generator to test assignment operator.
301 struct assignable
303 template<typename _T>
304 void
305 operator()()
307 _T v1;
308 _T v2;
309 v1 = v2;
313 // Generator to test default constructor.
314 struct default_constructible
316 template<typename _T>
317 void
318 operator()()
320 _T v;
324 // Generator to test copy constructor.
325 struct copy_constructible
327 template<typename _T>
328 void
329 operator()()
331 _T v1;
332 _T v2(v1);
336 // Generator to test explicit value constructor.
337 struct explicit_value_constructible
339 template<typename _Ttype, typename _Tvalue>
340 void
341 operator()()
343 _Tvalue a;
344 _Ttype v(a);
348 } // namespace __gnu_test
349 #endif